- Developers who already know basic commit and branch actions
- Readers who want to understand command boundaries and risk
Command Reference
git-shortlog Tutorial
Explains how to use git-shortlog to summarize commit history by author and subject.
- A basic mental model of worktree, index, and commits
- Comfort reading `git status` and a small commit graph
- Using local cleanup commands on already shared history
- Continuing to rewrite before confirming a recovery path
Citations & Further Reading
- Git shortlog [Official]
- Distributed Git Maintaining a Project [Book]
What you will learn
- Understand the core purpose of git-shortlog Tutorial
- Master the basic usage and common options of git-shortlog Tutorial
- Explains how to use git-shortlog to summarize commit history by author and subject.
- Understand key concepts: When it is a good fit
- Know when to use this feature and when to avoid it
Start with a problem
You're working in a Git repository and need to perform a specific task — but you're not sure which command or option is the right fit, or what this command can and cannot do.
The short version
git-shortlog is used to summarize commit history by author and subject.
When it is a good fit
- when you need to summarize commit history by author and subject
- when you want this step to be repeatable instead of ad hoc
- when you need a clearer mental model of what Git is recording or updating
Basic example
git shortlog -sn
What to watch most closely
Learn the default behavior first. Many surprises come from adding flags before the base behavior is clear.
A safer working habit
Pair it with status, log, or diff so you can confirm what actually changed.
Useful angles for understanding it
- Understand the default behavior clearly
- Use it in day-to-day Git routines
- Reuse it safely in scripts or team habits
Related reading
Read it alongside git status, git log, and git show so it is easier to see how the command changes history, refs, the index, or the working tree.
What problem this command solves in a workflow
git shortlog solves the problem of "I need commit information grouped by author." It takes git log output, groups commits by author, and counts them — suitable for generating release notes, contributor lists, or team workload statistics.
Typical use cases
- When releasing a new version, use
git shortlog -sn v1.0..v2.0to generate a contributor list sorted by commit count for the release notes. - Review a version's changes with
git shortlog --no-mergesto filter out merge commits and see only actual code contributions. - Use
git shortlog -sneto display author names, emails, and commit counts together for contributor reports.
Diagram view
Special cases and boundaries
git shortlogreads from stdin by default (commonly used in a pipe likegit log | git shortlog). If run directly without a tty it may produce no output. When running directly, add a commit range likeHEADorv1.0..v2.0.- It only reads commit history and does not modify anything in the repository — it is a purely read-only command.
- With
-sonly the count is shown; without it, each commit's subject line is also displayed. - Merge commits are also counted; to exclude them, pair with
--no-merges(usually viagit log --no-merges | git shortlog).
Try it yourself
- Practice the git-shortlog command in a test repository and observe state changes before and after
- Experiment with different options and compare the output differences
- Simulate a real scenario where you would need to use this, and walk through the full process
Further reading
Keep going on the same topic: