How to revert last X commits in git?


$ 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.

Leave a Reply