How to Undo Your Most Recent Commit in Git

If you want to do undo your last commit in Git what you will do is type the following command on your Terminal (Mac) or Command Prompt (Windows)

git reset HEAD~

This will leave your working tree unchanged but undo the commit. After this you will see all files from your commit back in un-staged status. Now you can make your changes and add back the files and commit again.

Also, if you are only trying to undo the message from your last commit then you can type the following command:

git commit -- amend

This will open up you Vim (or your custom editor in case you have changed it). You can modify the message and save. If you will like to see a video of all this being performed please watch the video below.

Posted in Git

Leave a Reply

Your email address will not be published. Required fields are marked *