Undo a Commit in Git

February 19, 2015

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
comments powered by Disqus