How to cancel last local commit in git

I keep forgetting this. If you want to delete the latest commit that you have not pushed, you can do it using:

$ git reset HEAD~1

This will remove the commit and leave your changes untouched. If you want to get rid completely of the change, you can use git checkout

$ git checkout .

Leave a Reply

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