Git:检出除一个之外的所有文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20008025/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 17:19:05 来源:igfitidea点击:
Git: Checkout all files except one
提问by Kyle
When I do a git status, I see files like this:
当我执行 git status 时,我看到如下文件:
modified: dir/A/file.txt
modified: dir/B/file.txt
modified: dir/C/file.txt
modified: dir/D/file.txt
What I want to do is to discard changes to all files EXCEPT for dir/C/file.txt
我想要做的是放弃对所有文件的更改,除了 dir/C/file.txt
I want to do something like this:
我想做这样的事情:
git checkout -- dir/!C/file.txt
回答by mechanicalfish
git add dir/C/file.txt # this file will stay modified and staged
git checkout .
If you want to unstage the file after that:
如果您想在此之后取消暂存文件:
git reset