171

I would like git to give me a list of all the files modified by one user, across all commits.

My particular use case is that I've been involved in the i18n of a ruby on rails project, and we want to know what files have already been done and what files still need to be done. The users in question have only done work on the i18n, not on the rest of the code base. So the information should all be in git, but I'm not sure how to get it out.

Thomas W
  • 14,757
  • 6
  • 48
  • 67
Hamish Downer
  • 16,603
  • 16
  • 90
  • 84

5 Answers5

233

This will give you a simple list of files, nothing else:

git log --no-merges --author="Pattern" --name-only --pretty=format:"" | sort -u

Switch --author for --committer as necessary.

Ian Kelling
  • 9,643
  • 9
  • 35
  • 39
h0tw1r3
  • 6,618
  • 1
  • 28
  • 34
160

This isn't the only way, but it works:

git log --pretty="%H" --author="authorname" |
    while read commit_hash
    do
        git show --oneline --name-only $commit_hash | tail -n+2
    done | sort | uniq

Or, as one line:

git log --pretty="%H" --author="authorname" | while read commit_hash; do git show --oneline --name-only $commit_hash | tail -n+2; done | sort | uniq
Steve Prentice
  • 23,230
  • 11
  • 54
  • 55
10

Try git log --stat --committer=<user>. Just put the user's name on the --committer= option (or use --author= as appropriate).

This will spit out all the files per commit, so there will likely be some duplication.

Robert S.
  • 25,266
  • 14
  • 84
  • 116
1
git log --pretty= --author=@abcd.com --name-only | sort -u | wc -l

Shows all modified files by company in the git repo.

git log --pretty= --author=user@abcd.com --name-only | sort -u | wc -l

Shows all modified files by author name 'user' in the git repo.

  • 1
    Note that OP asked for a list of files while your answer currently only gives the count because of the `| wc -l` (which might be off by one as [noted by joachim](https://stackoverflow.com/questions/6349139/can-i-get-git-to-tell-me-all-the-files-one-user-has-modified/6349483#comment84085743_6349483)). Good addition, though, for noting that one can use it to search for "company contributions" by means of the email address (although a [`.mailmap` file](https://git-scm.com/docs/gitmailmap) might be mandatory for this to work correctly as people sometimes commit with different email addresses)! – Marcus Mangelsdorf Jan 04 '22 at 15:04
  • A thing of beauty. Thanks. – daparic Mar 11 '22 at 10:46
-1

If you only want the list of filename:

git log --author= --pretty=format:%h | xargs git diff --name-only | sort | uniq

Knard
  • 1
  • 1
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 20 '22 at 00:33