February 19, 2015

Undo a Commit in Git

I keep forgetting how to do this, so I thought I’d post this for my own future benefit:

// Completely deletes the most recent commit
$ git reset --hard HEAD~1

// Removes the most recent commit, but leaves changes intact. Useful if you
// might want to make a new commit.
$ git reset --soft HEAD~1

Did You Enjoy This Post?