0

I often use git log --name-only when viewing the log to see what files each commit changed or introduced. Git tacks on a list of file paths to each log entry.

However, if you use git log --name-only path-to-file you will just get the commits involving that file as expected, but it will only additionally list the file specified rather than the full list of files that commit changed. Making it quite useless. This behavior was seen for Git version 2.1.4.

Is there a different incantation available to list all files changed per commit when viewing the log for a particular file?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
kcghost
  • 256
  • 1
  • 11
  • 1
    Possible duplicate of [How to list all the files in a commit?](https://stackoverflow.com/questions/424071/how-to-list-all-the-files-in-a-commit) – Tim Biegeleisen Aug 13 '17 at 14:56
  • 1
    I'm fairly certain that there is already a Stack Overflow question/answer which covers your question. Try searching for it before posting. – Tim Biegeleisen Aug 13 '17 at 14:56
  • @TimBiegeleisen I have searched before posting. As far as I am aware this is not a duplicate. The question you referenced is for listing the changed files for a particular commit, not when viewing a log of commits. I have looked through it for potential answers anyway, but found none. – kcghost Aug 13 '17 at 15:09

2 Answers2

1

I believe that you're are asking for git log -p --full-diff. Here is the definition from that command:

--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.

You can see this web page to search for more advanced ways to search logs.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • Thanks, `git log --full-diff --name-only path-to-file` results in the behavior I was looking for. – kcghost Aug 13 '17 at 15:22
0
git log --pretty=%H $FILENAME | while read sha1
do
    git show --pretty='%nCommit: %h' --name-only $sha1
done
phd
  • 82,685
  • 13
  • 120
  • 165