[null, null, null, {"document_url": "http://djgamedesigner.blogspot.com/2014/02/github-trick-delete-all-changes.html", "unformatted_src": "http://i.imgur.com/I8u76.png", "src": "http://i.imgur.com/I8u76.png", "formatted_filename": "I u", "rendered_width": 246, "rendered_height": 230}, null, null, {"document_url": "http://djgamedesigner.blogspot.com/2014/02/github-trick-delete-all-changes.html", "unformatted_src": "//1.bp.blogspot.com/-3nSKiNYx8rk/T_HShoBjy8I/AAAAAAAAAGo/kWqxzYw2HoA/s80/boo.png", "src": "http://1.bp.blogspot.com/-3nSKiNYx8rk/T_HShoBjy8I/AAAAAAAAAGo/kWqxzYw2HoA/s80/boo.png", "formatted_filename": "boo", "alt_text": "My photo", "rendered_width": 80, "rendered_height": 68}, null]

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!
Posted by Dan Jorquera at 5:51 PM