Git: Checkout all files except one

纵然是瞬间 提交于 2019-12-03 04:42:33

问题


When I do a git status, I see files like this:

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

I want to do something like this:

git checkout -- dir/!C/file.txt

回答1:


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


来源:https://stackoverflow.com/questions/20008025/git-checkout-all-files-except-one

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!