Search code examples
gitgit-log

Show all files affected by a commit with git log when given only one file


I would like to git log file and have it show the full commit details, including all files affected by that commit, like git log --stat=999,999 produces.

For example, git log --stat=999,999 path/to/file shows a diffstat of just that one file and if its associated commit had more files in it then it won't show them. I'd like it to show all files of the commit.


Solution

  • You can get what I think you are looking for with:

    git log --format=%H $filename | while read x; do git show --stat $x; done
    

    or

    git show --stat $(git rev-list HEAD -- $filename)
    

    (These are variations on a theme.) If you have to deal with historical renames, you may want to use git log --follow.