如何在选定的提交中制作`git log --stat - <path>`show*all*文件?

ntc*_*tc2 8 git

当我使用<path>参数git log --stat来限制日志以提交修改时<path>,git列表<path>作为显示所选提交时唯一的修改文件.我希望看到为每个选定的提交列出的所有修改路径.

例如:

$ echo test > a.txt
$ echo test > b.txt
$ git add a.txt b.txt
$ git commit -m test
 [...]
 2 files changed, 2 insertions(+), 0 deletions(-)
 [...]
$ git log -n1 --stat
 [...]

 a.txt |    1 +
 b.txt |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)
$ git log -n1 --stat -- a.txt
 [...]

 a.txt |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Run Code Online (Sandbox Code Playgroud)

请注意,第二个git log,带有path参数a.txt,表示"1个文件已更改",实际上"2个文件已更改".我想混帐告诉我,无论a.txt和b.txt改变,即使我选择了基于路径上提交a.txt.

更新:@jacknagel回答了我的问题,但事实证明他的解决方案在我的实际用例中不起作用.在我的实际用例中,我正在寻找修改文件的所有提交,包括重命名,在两个相关项目分歧的情况下.我需要弄清楚一个项目中的哪些变化意味着在另一个项目中有相应的变化(我需要做出).不幸的是,git抱怨时,我尝试使用--full-diff,并--follow在同一时间.

所以,在我的实际情况中,我正试图运行:

git log --stat --follow -- a.txt
Run Code Online (Sandbox Code Playgroud)

在这种情况下有效的解决方案是:

git log --format='%H' --follow -- a.txt | xargs git show --stat -C
Run Code Online (Sandbox Code Playgroud)

小智 11

您可以使用以下--full-diff选项获得此行为:

   --full-diff
       Without this flag, "git log -p <path>..." shows commits that touch
       the specified paths, and diffs about the same specified paths. With
       this, the full diff is shown for commits that touch the specified
       paths; this means that "<path>..." limits only commits, and doesn't
       limit diff for those commits.

       Note that this affects all diff-based output types, e.g. those
       produced by --stat etc.
Run Code Online (Sandbox Code Playgroud)