Undo a commit and redo
$ git commit ... (1)
$ git reset --soft HEAD~1 (2)
<< edit files as necessary >> (3)
$ git add .... (4)
$ git commit -c ORIG_HEAD (5)
- This is what you want to undo
- This is most often done when you remembered what you just committed is incomplete, or you misspelled your commit message1, or both. Leaves working tree as it was before "commit".
- Make corrections to working tree files.
- Stage changes for commit.
- Commit the changes, reusing the old commit message. reset copied the old head to .git/ORIG_HEAD; commit with -c ORIG_HEAD will open an editor, which initially contains the log message from the old commit and allows you to edit it. If you do not need to edit the message, you could use the -C option instead.