Monday, February 3, 2014

GitHub Trick: Delete ALL Changes

What happened to the year 2013? It seems I disappeared for a bit. I'm going to attempt to use this blog a bit more often.

First post back, I'd like to post one of my most used tricks. Sometimes, when using GitHub for proper version control (which everyone should do!), you'll find that you have, quite literally, a thousand changes that you don't want. Perhaps you updated an iOS application with some broken code and a lot of useless Xcode files. Maybe you tried moving a whole bunch of files from one directory to the other, and it didn't work out. Whatever it may be, it can be really annoying using a GitHub GUI to discard individual changes - and if your GUI happens to let you discard all changes, it might not actually remove them all.

So! Here's a quick trick you can throw into your terminal window or command prompt. I have found this trick through extreme googling and rigorous trial and error.

git reset --hard #
git clean -fd .
git checkout -- .

That's it! Hopefully this helps someone get back to normalcy within their project. Good luck!

No comments:

Post a Comment