Git undo a commit and redo
When you need to undo your last git commit…
$ git commit ... (1)
$ git reset --soft HEAD~1 (2)
<< make corrections >> (3)
$ git add .... (4)
$ git commit -c ORIG_HEAD (5)
- The last commit what should be undone.
- Reset to the parent “commit”, “soft” option does not touch the index file or the working tree at all, but resets the head to
, . - Make corrections to working tree files.
- Stage changes for commit.
- Commit the changes.