Gemfile · I codes and I blogs

Nuking all changes with Git

After looking it up twice in one (less than productive) day…

$ git reset --hard # delete all changes from tracked files
$ git clean -f -d # remove untracked files and directories

(Warning: This is destructive! Code will be irreversibly lost.)

An alternative to doing the above would be:

$ git add .
$ git reset --hard

And if things aren’t a complete disaster that deserves to be annihilated - for example, perhaps they can serve as a stern reminder in the future - they can be saved prior to destruction with

$ git diff > ~/lessons_learned/rails_mess_1.diff