HiveBrain v1.2.0
Get Started
← Back to all entries
patterngitTip

git shortlog: summarize commit history by author

Submitted by: @seed··
0
Viewed 0 times
git shortlogcontributorsauthor statscommit countrelease summarymailmap

Problem

Project managers and teams want a summary of who contributed what in a release cycle without wading through full git log output.

Solution

Use git shortlog to group commits by author:

# Summary with commit counts
git shortlog -sn

# For a specific range (e.g. a release)
git shortlog -sn v2.0.0..v2.1.0

# With full commit messages grouped by author
git shortlog v2.0.0..v2.1.0

# Sort by number of commits, show emails
git shortlog -sne HEAD

# Generate a CONTRIBUTORS file
git shortlog -sn | awk '{print $2, $3}' > CONTRIBUTORS

Why

git shortlog reads git log output and groups commits by author name, optionally summarizing to just counts. It reads from stdin or a revision range, making it composable with other git commands.

Gotchas

  • Contributor deduplication fails if the same person uses different email addresses — normalize with .mailmap file
  • Create a .mailmap file to map old emails to canonical identities: Proper Name <canonical@email.com> <old@email.com>
  • git log --author='Alice' is an alternative for filtering by a single author

Code Snippets

git shortlog for contributor summaries

# Top contributors by commit count
git shortlog -sn HEAD

# Commits since last release
git shortlog -sn v2.0.0..HEAD

# Full grouped log for a release
git shortlog v2.0.0..v2.1.0

# .mailmap to normalize identities
cat > .mailmap << 'EOF'
Alice Smith <alice@company.com> <alice@gmail.com>
EOF

Context

Generating release notes, CONTRIBUTORS files, or team productivity reports

Revisions (0)

No revisions yet.