开发者

How do I git-revert from the command line?

开发者 https://www.devze.com 2023-02-18 13:32 出处:网络
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

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

How do I git-revert from the command line?

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号