Blake Taylor
Blake Taylor

Reputation: 9341

Display all files, by a user contributed, in a repo

What's the simplest way to list all the files in a git repo a particular user contributed.

Upvotes: 1

Views: 236

Answers (3)

Mark Longair
Mark Longair

Reputation: 467071

The following does what you want, I think:

git log --diff-filter=A --author='Someone' --name-only --pretty=format: | sort -u

Note that the --diff-filter=A says to only report files that were added, and the --pretty=format: is just to suppress the normal output of the commit message from git log.

Note that this is just showing the addition of files in commits by a particular author - in the vast majority of cases it won't accurately reflect their contribution to a project, for example.

Upvotes: 2

Jonas Schäfer
Jonas Schäfer

Reputation: 20718

I would suggest one of these:

# commit + full message + list of changed files
git log --author="Frank Nord" --stat

# commit + full message
git log --author="Frank Nord"

# just commit + one line message
git log --author="Frank Nord" --format=short   

For further options on --format and infos on patterns supported by --author see git log --help.

If you really need only the files, you'll need to do some grepping:

git log --author="Frank Nord" --stat --format=oneline | grep -Po "(?<=^ ).*(?=\|)" | grep -Po "[^ ]+(\s*[^ ]+)*" | sort | uniq

This gives you a list of unique paths ever touched by Frank Nord. It actually needs two stages of grep here, grep otherwise error'd with exceeded PCRE's backtracking limit :)

Upvotes: 2

Hassek
Hassek

Reputation: 8995

you could always use grep for it:

git log | grep -B 2 -A 3 'Author: Timmy'

-B num means the number of lines to show before the match and -A num the number of lines after the match

Upvotes: 0

Related Questions