How do I git-revert from the command line?

ripper234 picture ripper234 · Mar 17, 2011 · Viewed 41.7k times · Source

When I do git revert via TortoiseGit, I get this lovely window :

enter image description here

However, when I want to do the same from the command line, the documentation manages to completely confuse me. How do I revert all local uncomitted changes?

Answer

William Pursell picture William Pursell · Mar 17, 2011

To discard all local changes, you do not use revert. revert is for reverting commits. Instead, do:

$ git reset --hard

Of course, if you are like me, 7 microseconds after you enter that command you will remember something that you wish you hadn't just deleted, so you might instead prefer to use:

$ git stash save 'Some changes'

which discards the changes from the working directory, but makes them retrievable.