GIT.WTF !?! Submit Article

How to revert last X commits?

Written by Mandeep Singh in Mistakes Correction
git reflog
# you will see a list of every thing you've done in git, across all branches!
# each one has an index [email protected]{index}
# find the one before you broke everything
git reset [email protected]{index}
# magic time machine

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

Sign up below to receive updates, tips and more handy tutorials when git screws up. It’s good stuff & I don’t spam.