Git, revert last commitLast updated
Sometimes I make a commit accidentally or make a mistake; miss a file, add a file I shouldn't, leave a debug (print statement), etc.
I need to fix the mistake, and pretend it never happened in the first place. So I need to revert the last commit.
I do it with:
git reset HEAD~ . // do your stuff git add <your files> git commit -c ORIG_HEAD
git commit -c ORIG_HEAD command will open the editor with previous commit message. Edit away.
-C argument means you don't need to change the commit message.