Submit

How to revert last X commits

· OhShitGit · 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.

Want to Contribute?

Send me an Email, ping me on Twitter or submit a pull request on Github.

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