- 在git checkout中的干运行选项 [英] --dry-run option in git checkout
问题描述
我使用 git checkout - < dir_name(或)file_name>
来放弃特定目录或文件中的所有更改。每当我这样做时,GIT都会检查存储库中的目录(或)文件。
I use git checkout --<dir_name(or)file_name>
to discard all my changes in the specific directory or in the file. Whenever I do that, GIT checks-out the directory (or) file from the repository.
有没有办法告诉GIT?,不要重写更改,告诉我会发生什么。
Is there a way I can tell GIT?, "do not override the changes, just tell me what would happen."
与类似> git clean -n
(或) git clean --dry-run
。
更新:
在我执行之前, git checkout --src /
,我想看看哪些文件会被覆盖。我知道我们可以使用 git status src /
。但是,如果 git checkout -n --src /
不是很好吗?
UPDATE:
Before I execute, git checkout --src/
, I would like to see what are the files would be overridden. I know we can use git status src/
. But, wouldn't it be great to have git checkout -n --src/
? Not much command changes for the user.
推荐答案
您可以运行
You can run
$ git checkout --patch -- <files>
,它会询问每个区别是否要检查该区别。如果您对每个提示都说不,那么它就会保持不变。
and it will ask for each difference whether you want to "check out" that difference. If you say no for each prompt, then it leaves it untouched.
这篇关于 - 在git checkout中的干运行选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!