No nível 45 do Githug, inicialmente havia um mal-entendido sobre o git rebase -i. Vou registrar o uso correto.
carol@macmini:~/git_jogo$ githug reset 45
********************************************************************************
* Githug *
********************************************************************************
resetting level
Name: rename_commit
Level: 45
Difficulty: ***
Correct the typo in the message of your first (non-root) commit.
carol@macmini:~/git_jogo$
Identifique o commit com o erro de digitação:
carol@macmini:~/git_jogo$ git log
commit d30bc005638c278714faaa73f0fdc16052561750 (HEAD -> master)
Author: josé <jose@exemplo.com>
Date: Fri Jun 29 11:35:05 2018 +0800
Segundo commit
commit 4f1341ac9134225719e5d704e420160657e8c38e
Author: josé <jose@exemplo.com>
Date: Fri Jun 29 11:35:05 2018 +0800
Primeiro coommit # <-- erro: "coommit" em vez de "commit"
commit a632e3dfa31a06bcec9395c0690d43a3f2f09706
Author: josé <jose@exemplo.com>
Date: Fri Jun 29 11:35:05 2018 +0800
Commit inicial
carol@macmini:~/git_jogo$
Execute git rebase -i apontando para o pai do commit problemático:
carol@macmini:~/git_jogo$ git rebase -i a632e3dfa31a06bcec9395c0690d43a3f2f09706
O editor abrirá com o conteúdo:
pick 4f1341a Primeiro coommit
pick d30bc00 Segundo commit
# Rebase a632e3d..d30bc00 onto a632e3d (2 commands)
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
~
~
~
~
~
"~/git_jogo/.git/rebase-merge/git-rebase-todo" 21L, 693C
Altere pick para reword (ou apenas r) no commit com erro:
r 4f1341a Primeiro coommit
pick d30bc00 Segundo commit
# ... (as linhas de comentário permanecem)
~
~
-- INSERT --
Salve e saia (:x). O editor abrirá novamente para editar a menasgem do commit:
Primeiro coommit
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Fri Jun 29 11:35:05 2018 +0800
#
# interactive rebase in progress; onto a632e3d
# Last command done (1 command done):
# r 4f1341a Primeiro commit
# Next command to do (1 remaining command):
# pick d30bc00 Segundo commit
# You are currently editing a commit while rebasing branch 'master' on 'a632e3d'.
#
# Changes to be committed:
# new file: arquivo1
#
~
~
~
"~/git_jogo/.git/COMMIT_EDITMSG" 17L, 520C
Corrija o erro: troque "coommit" por "commit":
Primeiro commit
# ... (restante inalterado)
~
-- INSERT --
Salve e saia novamente (:x). O terminal mostrará a conclusão do rebase:
carol@macmini:~/git_jogo$ git rebase -i a632e3dfa31a06bcec9395c0690d43a3f2f09706
[detached HEAD ea3efe3] Primeiro commit
Date: Fri Jun 29 11:35:05 2018 +0800
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 arquivo1
Successfully rebased and updated refs/heads/master.
Verifique o log:
carol@macmini:~/git_jogo$ git log
commit 1f929783b1acb295aaf7b9dbe500629a1054484f (HEAD -> master)
Author: josé <jose@exemplo.com>
Date: Fri Jun 29 11:35:05 2018 +0800
Segundo commit
commit ea3efe310a6a03a232171bf664401f62a5dc024e
Author: josé <jose@exemplo.com>
Date: Fri Jun 29 11:35:05 2018 +0800
Primeiro commit # <-- corrigido!
commit a632e3dfa31a06bcec9395c0690d43a3f2f09706
Author: josé <jose@exemplo.com>
Date: Fri Jun 29 11:35:05 2018 +0800
Commit inicial
carol@macmini:~/git_jogo$
Pronto! A mensagem foi corrigida com sucesso.