git: Undo a Commit
Posted by robert on Dec 30, 2021 in git
Sometimes right after you perform a commit in git you realize you made a mistake. For me it is usually that I commit a file I didn't want to or wasn't ready to.
The good news is that as long as you haven't pushed it to a remote repository it is relatively easy to fix.
Just perform the following steps:
$ git reset HEAD~
# Make the necessary changes
$ git add .
$ git commit -c ORIG_HEAD
That is it. You have now fixed your mistake.
You must be logged in to see the comments. Log in now!