How to make `git log --stat - <path>` show * all * files in selected commits?
When I use the <path> argument with git log --stat to restrict the git log --stat <path> , git lists the <path> as the only modified file when displaying the selected commits. I would like to see all the modified paths listed for each selected commit.
For instance:
$ 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(-) Note that the second git log , with the path a.txt argument, says β1 file changedβ when in fact β2 files changedβ. I would like git to tell me that both a.txt and b.txt have changed, although I chose to commit based on the a.txt path.
UPDATE: @jacknagel answered my question, but it turned out that his solution does not work in my real use case. In my actual use case, I am looking for all the commits that modified the file, including renaming, in the case where two related projects diverged. I need to find out what changes in one project involve corresponding changes (I have to make) in another project. Unfortunately, git complains when I try to use --full-diff and --follow at the same time.
So, in my real situation, I am trying to run:
git log --stat --follow -- a.txt and a solution that works in this case:
git log --format='%H' --follow -- a.txt | xargs git show --stat -C You can get this behavior using the --full-diff option:
--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, eg those produced by --stat etc. First find the commit identifiers, then pass them to xargs (or gnu parallel ) to pass each git show identifier.
git log --format='%H' --follow -- a.txt | xargs git show --stat -C On windows with powershell, something like this should work (but I haven't tested it yet.):
git log --format='%H' --follow -- a.txt | ForEach-Object { git show --stat -C $_ }