Last Updated: February 25, 2016
· rvazquez

Revert All Local Changes in Git

You're coding. Everything is going well until disaster strikes. You try to fix the problem but every fix seems to take you down a path of interminable doom. You have to abandon ship.

Fear not. There is an easy way for you to revert all the changes that you've made to your local copy of the Git Repository. It goes like this:

git checkout ./

Boom. That's it. You can tell yourself every genius gets misguided sometimes; it's okay. Keep making magic.

Not everyone gets a second chance, you know?

2 Responses
Add your response

I've always been using git reset --hard for cases like these. That however undoes changes you have already staged with git add though.

Reset can be useful if you've started resolving a merge conflict and realize you've going at it all wrong.

over 1 year ago ·

@michd I knew about --hard but didn't know that it undoes staged changes. Thanks for the tip man!

over 1 year ago ·