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
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 shortlogOptions
| Flag | What it does |
|---|---|
| -s / --summary | Show counts, not commit subjects |
| -n / --numbered | Sort by number of commits |
| -e / --email | Show author email |
| --no-merges | Exclude 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.
- 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