The Spaghetti Refactory Established 2015

Undo your last git commit

If you check my Google search history, one of the most frequent searches you'd probably see is "undo git commit." This is primarily from pulling the latest master or staging branch, making changes and committing accidentally before creating a new branch. So, I create the new branch with my new commit on it, but then I want to switch back to master or staging and nuke that last commit. Here's the very simple one-liner I use, taken directly from this extremely helpful StackOverflow answer:

git reset --hard HEAD~1

Make SURE you have created that new branch so that you have your commit somewhere else, because this git command will completely erase your commit from the branch in which you are currently working.