Lesson 18 of 6810 min read

git shortlog: Summarized Contribution Stats Per Author

Learn how git shortlog groups and summarizes commit history by author, giving a quick overview of who contributed what.

Author: CodersNexus

git shortlog: Summarized Contribution Stats Per Author

While `git log` lists commits chronologically, `git shortlog` reorganizes the same history around authors — grouping every commit by who made it, and optionally just summarizing counts. It's the fastest way to get a high-level view of who has contributed what to a project, often used when preparing release notes or contributor summaries.

Learning Objectives

  • Use git shortlog to group commit history by author.
  • Use the -s and -n flags to show summarized, sorted contribution counts.
  • Understand how shortlog differs from git log in purpose and output structure.
  • Apply shortlog for practical use cases like release notes and contributor reports.

Key Terms to Know Before Learning git shortlog

  • git shortlog: A command that summarizes git log output, grouping commits by author.
  • -s (summary): A shortlog flag that shows only the commit count per author, omitting individual commit messages.
  • -n (numeric sort): A shortlog flag that sorts authors by number of commits, from most to least, instead of alphabetically.
  • Contributor report: A summary of who contributed how much to a project, often generated using shortlog for changelogs or team retrospectives.

How git shortlog Actually Works

Running `git shortlog` with no flags groups every commit under its author's name, listing each commit's message (without the hash, date, or diff) beneath the corresponding author heading:

```
Asha Mehta (3):
feat: add login validation
fix: correct navbar spacing
docs: update README

Rohit Sharma (2):
feat: add dark mode toggle
fix: resolve checkout error
```

This reorganization — by author rather than by time — makes it easy to see at a glance what each contributor has been working on, without manually sifting through an interleaved chronological list.

For an even more condensed view, the `-s` (summary) flag drops the individual commit messages entirely, showing only each author's total commit count:

```
git shortlog -s
3 Asha Mehta
2 Rohit Sharma
```

Combined with `-n` (numeric sort), authors are ordered by commit count, from highest to lowest, rather than alphabetically — useful for quickly seeing who has contributed the most commits to a project:

```
git shortlog -sn
```

Like `git log`, `shortlog` respects the same filtering flags covered earlier in this module — you can combine it with `--since`, `--author`, or a specific branch/tag range to scope the summary to a particular period or subset of history. For example, generating a summary of contributions since the last release tag is a common real-world use:

```
git shortlog -sn v1.0.0..HEAD
```

This shows commit counts per author for everything committed since the `v1.0.0` tag, which is exactly the kind of summary often included at the top of release notes to credit contributors.

git shortlog: Visual Walkthrough

Show two side-by-side panels. Left panel labeled 'git log (chronological)': a vertical list mixing commits from different authors in time order — 'Asha: fix navbar', 'Rohit: dark mode', 'Asha: login validation', 'Meera: update docs'. Right panel labeled 'git shortlog (grouped by author)': three author headings — 'Asha Mehta (2)', 'Rohit Sharma (1)', 'Meera Nair (1)' — each with their respective commits listed underneath. An arrow between panels labeled 'reorganizes the same commits by author'.

Command vs Output: Key Differences

CommandOutput
git shortlogCommits grouped by author, with each commit message listed
git shortlog -sOnly commit counts per author, no individual messages
git shortlog -snCommit counts per author, sorted from most to least commits
git shortlog -sn v1.0.0..HEADCommit counts per author, scoped to changes since a specific tag

git shortlog: Command Syntax and Examples

# Full shortlog grouped by author
git shortlog

# Summary: just commit counts per author
git shortlog -s

# Summary sorted by commit count, highest first
git shortlog -sn

# Contribution summary since the last release tag
git shortlog -sn v1.0.0..HEAD

# Combine with a date filter (same flags as git log)
git shortlog -sn --since="1 month ago"

Breaking Down the git shortlog Example

The plain `git shortlog` groups all commits under their respective authors, listing each commit's message beneath. Adding `-s` condenses this to just the count of commits per author, and `-sn` further sorts that list from the most prolific contributor down. Scoping with a tag range (`v1.0.0..HEAD`) restricts the summary to only commits made since that release, which is exactly the kind of snapshot used when crediting contributors in release notes. The final example shows that shortlog accepts the same date-filtering flags as git log, letting you generate a 'contributions this month' summary just as easily.

How git shortlog Is Used on Real Engineering Teams

  • Open-source projects frequently include a git shortlog -sn v1.0.0..v1.1.0 summary at the top of their release notes to explicitly credit every contributor since the previous version.
  • Engineering team leads sometimes use git shortlog -sn --since="1 month ago" during retrospectives to get a quick, informal pulse on contribution activity (while being careful not to treat raw commit counts as a proxy for code quality or effort).
  • Conference and community organizers use shortlog output when preparing 'thank you' contributor lists for major open-source releases.
  • Some automated changelog generation tools use shortlog-style grouping internally to organize release notes by contributor alongside categorized commit messages.

git shortlog Interview Questions and Answers

Q1. What is the difference between git log and git shortlog?

git log lists commits chronologically, interleaving contributions from all authors in time order. git shortlog reorganizes the same commit history by grouping it under each author's name, making it easier to see contributions per person rather than per point in time.

Q2. How would you get a quick count of commits per author, sorted from most to least?

Run git shortlog -sn. The -s flag shows only the summary count per author (omitting individual commit messages), and -n sorts authors numerically by commit count, from highest to lowest.

Q3. How could you generate a contributor summary for everything committed since the last release tag?

Use a range with shortlog, such as git shortlog -sn v1.0.0..HEAD, which scopes the summary to only commits made after the v1.0.0 tag, showing contribution counts per author for that specific period.

git shortlog Quiz: Test Your Understanding

1. What does git shortlog do differently from git log?

  1. It shows only the last commit
  2. It groups and reorganizes commit history by author
  3. It deletes old commits from history
  4. It only works on remote repositories

Answer: B. It groups and reorganizes commit history by author

Explanation: shortlog reorganizes the same commit history that git log shows chronologically, instead grouping it under each contributing author's name.

2. What does the -s flag do in git shortlog?

  1. Shows only a summary count of commits per author, omitting individual messages
  2. Sorts commits by date
  3. Shows only staged changes
  4. Displays commit hashes instead of messages

Answer: A. Shows only a summary count of commits per author, omitting individual messages

Explanation: The -s (summary) flag condenses shortlog output to just each author's total commit count, without listing individual commit messages.

3. What does combining -sn achieve in git shortlog?

  1. Shows commit counts per author sorted numerically from highest to lowest
  2. Filters commits to a specific author named 'sn'
  3. Shows only commits from the last n days
  4. Displays commits alphabetically by message

Answer: A. Shows commit counts per author sorted numerically from highest to lowest

Explanation: -s gives a summary count per author, and -n sorts that list numerically by commit count in descending order, making it easy to see top contributors at a glance.

git shortlog: Common Mistakes Beginners Make

  • Treating raw commit counts from shortlog as a direct measure of a developer's effort or value — commit count alone doesn't reflect complexity or impact of changes.
  • Forgetting that shortlog accepts the same filtering flags as git log (like --since or tag ranges), and manually filtering output instead.
  • Expecting shortlog to show diffs or detailed changes — it only summarizes at the message/count level, not code content.

git shortlog: Exam-Ready Quick Notes

  • git shortlog groups commits by author; git log lists them chronologically.
  • -s: summary count only per author. -n: sort numerically by count, descending.
  • -sn combined is the most common invocation for a quick top-contributors view.
  • Accepts the same range and date filters as git log (e.g., tag..HEAD, --since).

git shortlog: Key Takeaways

  • git shortlog reorganizes commit history around authors rather than chronological order, ideal for contributor summaries.
  • The -sn combination gives a fast, sorted view of who has contributed the most commits.
  • It supports the same filtering and range syntax as git log, making it easy to scope a summary to a release or time period.

Frequently Asked Questions About git shortlog

Q1. What is git shortlog used for?

It summarizes commit history grouped by author, making it easy to see at a glance who contributed what, rather than scrolling through a chronological git log mixing everyone's commits together.

Q2. How do I see just a count of commits per author?

Run git shortlog -s, which shows only each author's total commit count without listing individual commit messages.

Q3. How do I sort contributors by number of commits?

Combine the summary and numeric sort flags: git shortlog -sn. This lists authors from the most commits to the fewest.

Q4. Can I limit git shortlog to a specific time period or release?

Yes, it accepts the same filters and ranges as git log, such as git shortlog -sn --since="1 month ago" or git shortlog -sn v1.0.0..HEAD to scope the summary to commits since a specific tag.

Q5. Should commit count from shortlog be used to judge a developer's productivity?

No, it's not a reliable measure. Commit count doesn't reflect the complexity, size, or impact of changes — a single well-crafted commit can matter far more than several trivial ones.

Summary

`git shortlog` reorganizes commit history by grouping commits under each author's name, in contrast to `git log`'s chronological listing. The `-s` flag condenses this to just a commit count per author, and combining it with `-n` sorts that list numerically from most to least commits — `git shortlog -sn` being the most commonly used invocation. Like `git log`, shortlog accepts date filters and commit ranges (such as `tag..HEAD`), making it easy to generate a contributor summary scoped to a specific release or time period, a common ingredient in changelogs and release notes.

Frequently Asked Questions

It summarizes commit history grouped by author, making it easy to see at a glance who contributed what, rather than scrolling through a chronological git log mixing everyone's commits together.

Run git shortlog -s, which shows only each author's total commit count without listing individual commit messages.

Combine the summary and numeric sort flags: git shortlog -sn. This lists authors from the most commits to the fewest.

Yes, it accepts the same filters and ranges as git log, such as git shortlog -sn --since="1 month ago" or git shortlog -sn v1.0.0..HEAD to scope the summary to commits since a specific tag.

No, it's not a reliable measure. Commit count doesn't reflect the complexity, size, or impact of changes — a single well-crafted commit can matter far more than several trivial ones.