Skip to content
Tutorials Center
My learning

Topics

Git Reference ยท Inspecting History

git shortlog command

Reference for git shortlog: group commits by author, count contributions with -sn, include emails, group by committer or trailer, and avoid the stdin trap in scripts.

git shortlog summarizes the commit history, grouped by author. For each person it lists the subjects of their commits, or just a count with -s. It was written to produce release announcements ("who did what since the last version") and is still the quickest way to see who contributed to a project.

The grouping key can be changed from the author to the committer or to a commit message trailer such as Co-authored-by. You can restrict the history with the usual revision and date options, so git shortlog -sn v1.0..v2.0 gives a contributor ranking for one release.

Terminal
git shortlog [<options>] [<revision-range>] [[--] <path>...]

Try it

Bash Grouping and counting

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Committers and trailers

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
git shortlog [<options>] [<revision-range>] [[--] <path>...]
git log --pretty=short | git shortlog [<options>]
Option Description
-s, --summary Show only the number of commits per person.
-n, --numbered Sort by number of commits, largest first (default is alphabetical).
-e, --email Show the email address after each name.
-c, --committer Group by committer. Same as --group=committer.
--group=<type> Group by author (default), committer, or trailer:<field>. May be repeated; a commit then counts once in each group.
--format[=<format>] Show each commit as a line using a --pretty template instead of the subject.
-w[<width>[,<indent1>[,<indent2>]]] Wrap lines. Defaults to 76, 6, 9.
<revision-range> Limit the commits, for example v1.0..v2.0 or --since=2026-01-01.
-- <path>... Count only commits touching these paths.

Names are normalized through the mailmap (see .mailmap), so a person who used two spellings or addresses appears once.

Returns: exit status 0 on success, including when there are no commits.

Usage notes

  • The stdin trap. If you give no revision and standard input is not a terminal, git shortlog reads a log from standard input instead of reading history. In scripts and CI jobs this often yields empty output. Name a revision (git shortlog -sn HEAD) to be safe.
  • Commits, not lines. The count is the number of commits; one huge commit and one typo fix count equally. For lines, use git log --numstat or git blame.
  • Merge commits are counted like any other commit unless you add --no-merges.
  • Trailers must be in the trailer block at the end of the message; matching is case-insensitive on the field name.
  • Using --group=author plus --group=trailer:... lets you credit co-authors; the same person can appear in both groups, so totals can exceed the number of commits.
  • Sorting ties are broken alphabetically, which keeps output stable for release notes.
  • Different from git log --author. shortlog aggregates; log filters.