Run:
$ git rebase --interactive commit_hash^
each ^
indicates how many commits back you want to edit, if it's only one (the commit hash that you specified), then you just add one ^
.
Using Vim you change the words pick
to reword
for the commits you want to change, save and quit(:wq
). Then git will prompt you with each commit that you marked as reword so you can change the commit message.
Each commit message you have to save and quit(:wq
) to go to the next commit message
If you want to exit without applying the changes, press :q!
EDIT: to navigate in vim
you use j
to go up, k
to go down, h
to go left, and l
to go right( all this in NORMAL
mode, press ESC
to go to NORMAL
mode ).
To edit a text, press i
so that you enter the INSERT
mode, where you insert text.
Press ESC
to go back to NORMAL
mode :)
UPDATE: Here's a great link from github listing How to undo (almost) anything with git