Sample output
41 Ada Okafor <ada@payments.dev>
23 Marco Reyes <marco@payments.dev>
17 Sam Levine <sam@payments.dev>
9 Ada Okafor <ada.okafor@gmail.com>
2 Priya Nair <priya@payments.dev>
Ada appears twice, once per email address, so her real total is 50 and the repository has one dominant author rather than a close race. Run the same command without --no-merges and Sam jumps to 29, because twelve of those commits are pull request merges rather than code.
When you would reach for it
You have inherited a repository and need to know who to ask about it. You are writing release notes and want the list of contributors for a tag range. You suspect a project has a bus factor of one and want a number instead of a feeling. Shortlog answers all three in one line, and unlike counting surviving lines with git blame, it measures who has done the work over time rather than who touched the code last.
Gotchas
- Without a revision, shortlog reads from standard input whenever stdin is not a terminal. In a pipeline, a
$(...)substitution, or a CI job,git shortlog -snprints nothing and exits 0, which looks exactly like an empty repository. Always passHEADor a range. - The same person under two emails shows up as two rows with
-e, and two different people who share a name merge into one row without it. Neither view is correct on its own. A.mailmapfile at the repository root fixes it: the lineAda Okafor <ada@payments.dev> <ada.okafor@gmail.com>folds the second address into the first, and shortlog,git log, andgit blameall read it. - Commit counts measure commits, not effort. One person who squashes every branch into a single commit looks less active than someone who commits every save. Use the count to find people, not to rank them.
- Co-authors listed in
Co-authored-by:trailers are invisible by default, since shortlog counts the author header only.--group=trailer:co-authored-by(git 2.29 or later) counts them as well.
Variants
$ git shortlog -sn --no-merges v1.4.0..v1.5.0
Contributors to one release, the use shortlog was originally written for
$ git shortlog -sn --no-merges --since="6 months ago" HEAD -- src/billing/
Who has been active in one directory recently, which is usually who to ask
$ git shortlog -sn --no-merges --group=author --group=trailer:co-authored-by HEAD
Credit pair-programmed and co-authored commits to everyone named on them