Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding the most frequent committer to a specific file

Tags:

git

Given a specific file in a git repository, how would I go about finding who are the most frequent committers in that file?

like image 354
Léo Natan Avatar asked Dec 07 '16 09:12

Léo Natan


3 Answers

You can use git shortlog for this:

git shortlog -sn -- path/to/file

This will print out a list of authors for the path, ordered and prefixed by the commit count.

Usually, this command is used to get a quick summary of changes, e.g. to generate a changelog. With -s, the change summaries are suppressed, leaving only the author names. And paired with -n, the output is sorted by the the commit count.

Of course, instead of the path to a file, you can also use a path to a directory to look at the commits to that path instead. And if you leave off the path completely, git shortlog -sn gives you statistics for the whole repository.

like image 87
poke Avatar answered Sep 18 '22 15:09

poke


You can short output according to the number of commits per user.

$ git shortlog -sen <file/path>

Here,
-s for commit summary
-e for email
-n short by number instead of alphabetic order  

// more info
$ git shortlog --help
like image 24
Sajib Khan Avatar answered Sep 21 '22 15:09

Sajib Khan


$ git log --follow <file> | grep "Author: " | sort | uniq -c | sort

Some explanation:

git log --follow <file> - limit log to specific file, follow through all renames of this file

grep "Author:" | sort - take only lines with Authors and group authors together

uniq -c | sort - count authors in groups and sort it again, so most frequent one is in first line

:)

like image 22
Patryk Obara Avatar answered Sep 19 '22 15:09

Patryk Obara