Undoing a commit seems little difficult if you don’t know how to do it. But it’s actually pretty simple, here is simple commands for Undo a commit and redo
- $ git commit – This is what you want to undo
- $ git reset –soft HEAD^ – This is most often done when you remembered what you just committed is incomplete, or you misspelled your commit message, or both. Leaves working tree as it was before “reset”.
- $ edit – Make corrections to working tree files.
- $ git add – Stage changes for commit.
- $ git commit -c ORIG_HEAD – “reset” copies the old head to .git/ORIG_HEAD; redo the commit by starting with its log message. If you do not need to edit the message further, you can give -C option instead.