How do I git-revert from the command line?
When I do git revert via TortoiseGit, I get this lovely window :
However, when I want to do the same from the command line, the documentation m开发者_JS百科anages to completely confuse me. How do I revert all local uncomitted changes?
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.
Assuming you haven't committed yet, you can also:
git checkout filename(s)
Git newbies like me should be aware that working directory' != pwd
.
It rather means the whole tree.
So I'm thankful for Williams recommendation to use:
$ git stash save 'Some changes'
which can be undone via the following:
$ git stash pop
精彩评论