List all developers on a project in Git

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


List all developers on a project in Git



Is it possible to list all users that contributed to a project (users that have done commits) in Git?



Any additional statistics?




9 Answers
9



To show all users and the number of commits:


git shortlog --summary --numbered



Or simply:


git shortlog -sn





Note that if you want to use this command from within a script, or something like "ant", you must specify a revision or it outputs nothing. For the current revision you can use HEAD: git shortlog -sn HEAD
– Majenko
May 22 '14 at 18:03


git shortlog -sn HEAD





To get e-mail addresses as well, add -e.
– mic_e
Oct 30 '14 at 12:47


-e





To show users from all branches (not only the ones in the current branch) you have to add --all flag
– Gian Marco Gherardi
Jul 6 '15 at 6:58


--all





what if I dont want the number of commits?
– Wearybands
yesterday



If you want to be more specific in the list (find a list of unique committer and author), you could use git log:


git log


git log --pretty="%an %ae%n%cn %ce" | sort | uniq


%an


%ae


%n


%cn


%ce



Other placeholders are described in the pretty print documentation of git log.


git log





I think the %n does not make too much sense in combination with (line-based) sort, does it ? The line logs author / committer name / email in separate lines, but sorts over the entire output...
– ssc
Jun 27 at 12:21


%n


sort





@ssc committer email can be different from author email. %n is for new line to find those differences
– Guillaume Vincent
Jun 27 at 13:52



You can try this:


git log | grep Author: | sort | uniq





This is the most useful command for anyone interested in updating their .mailmap file!
– Ahi Tuna
May 2 at 17:02



(users that have done commits)



Note: by default git shortlog groups commits by authors.


git shortlog



If you need to group them by committers, you will need Git 2.12 (Q1 2017)


git shortlog -snc



See commit 03f4082 (16 Dec 2016) by Jeff King (peff).
See commit fbfda15 (11 Oct 2016) by Linus Torvalds (torvalds).
(Merged by Junio C Hamano -- gitster -- in commit ad1b4e2, 27 Dec 2016)


peff


torvalds


gitster



Linus Torvalds himself introduces this feature:


shortlog



In some situations you may want to group the commits not by author,
but by committer instead.



For example, when I just wanted to look up what I'm still missing from linux-next in the current merge window, I don't care so much about who
wrote a patch, as what git tree it came from, which generally boils
down to "who committed it".


linux-next


git tree



So make git shortlog take a "-c" or "--committer" option to switch grouping to that.


-c


--committer



I haven't got around to testing it myself yet, but this looks really nice for project statistics for a Git repository: https://github.com/visionmedia/git-extras



Check out the bin catalog to see the the different scripts.


bin



For example, the git-count script (commit count per committer):


git-count


git shortlog -n $@ | grep "):" | sed 's|:||'





git shortlog -ns seems less hackish
– TomDLT
Oct 20 '16 at 8:47





@TomDLT since I posted this 4 years ago, this example script in git-extras has changed. But I think my advice to look at git scripts from projects like git-extras or from peoples' dotfiles is still great advice. If you are looking for interesting git commands then I would recommend Gary Bernhardt's dotfiles as well: github.com/garybernhardt/dotfiles/tree/master/bin
– Daniel Lee
Oct 20 '16 at 8:54





Great answers by @pedro-nascimento, by @mic_e and others already solve the problem.



In addition, you can add the following line to your .gitconfig


.gitconfig


contributors = shortlog -e --summary --numbered



or in shell type


git config --global alias.contributors 'shortlog -e --summary --numbered'



You can try an amazing pack called git-extras. Specifically, the commands git-summary, git-count and maybe some other.



Another option can be:


git log --format='%aN' | sort -u



Most of the repositories contain multiple identities ([email, name] pairs) per author. If I can suggest a non-CLI solution, try Gitential which also deduplicates the author identities.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Keycloak server returning user_not_found error when user is already imported with LDAP

PHP parse/syntax errors; and how to solve them?

How to scale/resize CVPixelBufferRef in objective C, iOS