简体   繁体   English

如何列出将受到`git add .`影响的所有文件?

[英]how to list all the files that will be affected by `git add .`?

Is there a method that I list all files affected by git add. 有没有一种方法可以列出受git add.影响的所有文件git add. ?

Does the following command solve the problem? 以下命令是否解决了问题?

$ git ls-files -c -d -m -o

Thank you 谢谢

== Update == ==更新==

I have tried the git diff --stat and found that they are different from what git add . 我尝试过git diff --stat ,发现它们与git add .不同git add . does. 确实。

Here is an example: 这是一个例子:

$ git status -s
D  secondB.txt
 M shareLineFile.txt
?? fileA.txt

$ git diff --stat
 shareLineFile.txt | 1 +
 1 file changed, 1 insertion(+)

$ git add . --dry-run
add 'shareLineFile.txt'
add 'fileA.txt'
git diff --stat

This command will print summary of the files which will be added + number of lines when git add . 此命令将打印将添加的文件的摘要+ git add .时的行数git add . will be executed. 将被执行。

在此输入图像描述


Here is the git status for the above diff 这是上面差异的git状态

在此输入图像描述

git diff --stat is a fine answer, and will tell you the additions and deletions to files and such. git diff --stat是一个很好的答案,它将告诉你文件的添加和删除等。

However, to answer your original question "list the files affected by git add . ", you can just add the --dry-run option to see exactly what git add . 但是,要回答原始问题“列出受git add .影响的文件git add . ”,您只需添加--dry-run选项即可确切了解git add . would do: 会做:

% git add -n .
add 'foo/bar.py'
add 'README.md'
etc.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM