Skip to content
LatchkeyLatchkey home

git shortlog: Usage, Options & Common CI Errors

git shortlog groups commit subjects by author - the fast way to build contributor lists and changelogs.

shortlog is git log shaped for release notes. Pair it with a range and a mailmap for clean output.

What it does

git shortlog summarizes git log output by author, listing each author and the subject lines of their commits, optionally counting instead of listing.

Common usage

Terminal
git shortlog -sn              # authors by commit count
git shortlog v1.0.0..HEAD     # commits since a tag
git shortlog -sne             # include emails
git log --no-merges | git shortlog

Options

FlagWhat it does
-s / --summaryShow counts, not commit subjects
-n / --numberedSort by number of commits
-e / --emailShow author email
--no-mergesExclude merge commits
<range>Limit to a commit range

Common errors in CI

shortlog reads from a tty or piped log; in non-interactive CI pass an explicit range or pipe git log into it, otherwise it may wait for input. Authors split across multiple emails group separately - add a .mailmap to consolidate them.

Using this in CI

CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.

.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0   # history, tags, and git describe all need this

- run: |
    git rev-parse --is-shallow-repository   # expect false
    git rev-parse --abbrev-ref HEAD          # prints HEAD when detached

Frequently asked questions

git shortlog: Usage, Options & Common CI Errors?
shortlog is git log shaped for release notes. Pair it with a range and a mailmap for clean output.
What it does?
git shortlog summarizes git log output by author, listing each author and the subject lines of their commits, optionally counting instead of listing.
Common errors in CI?
shortlog reads from a tty or piped log; in non-interactive CI pass an explicit range or pipe git log into it, otherwise it may wait for input. Authors split across multiple emails group separately - add a .mailmap to consolidate them.

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card