How to revert the last X commits?

git reflog
# you will see a list of every thing you've done in git, across all branches!
# each one has an index HEAD@{index}
# find the one before you broke everything

git reset HEAD@{index}
# magic time machine

You can use this to get back stuff you accidentally deleted or remove some things you tried that broke the repo.

Originally Posted On: OhShitGit