git shortlog command
git shortlogThe command is used to generate a concise commit log summary, grouped by author and commit message.
git shortlogThe command is mainly used to summarize the commit history of a Git repository, providing an overview of commit counts per author and per commit category.
Basic Syntax
git shortlog [<options>] [<revision-range>]
<revision-range>: Specifies the commit range for which to generate the summary; defaults to all commits in the current branch.<options>: Options used to customize the output format or behavior.
Common options and usage:
| Options | Description | UsageExample |
|---|---|---|
-nor--numbered | Sorts authors by commit count, showing the number of commits for each author. | git shortlog -n |
-sor--summary | Shows only authors and their commit counts, without displaying commit messages. | git shortlog -s |
-eor--email | Display the author's email address. | git shortlog -e |
-cor--committer | Counts commits by committer rather than by author. | git shortlog -c |
-aor--all | Includes all authors (including those with no commits). | git shortlog -a |
--no-merges | Excludes merge commits, showing only a summary of non-merge commits. | git shortlog --no-merges |
--pretty | Customize the output format. | git shortlog --pretty=format:"%h %s" |
--since | Only show commits within the specified time range. | git shortlog --since="2023-01-01" |
--until | Only show commits before the specified time. | git shortlog --until="2023-01-01" |
--reverse | Displays the commit summary in reverse order, sorted by author commit count in ascending order. | git shortlog --reverse |
Common usage
1. Show commit authors and commit counts
Sorts authors by commit count, showing each author's commit count and the prefixes of their commit messages:
git shortlog -n
2. Show the commit count for each author
Shows only authors and their commit counts, without displaying commit messages:
git shortlog -s
3. Displays the author summary including email addresses
Show authors and their email addresses:
git shortlog -e
4. Exclude merge commits
Exclude merge commits, showing only a summary of non-merge commits:
git shortlog --no-merges
5. Statistics by committer
Count commits by committer rather than by author:
git shortlog -c
6. Show commits within a specific time range
Shows only the commit summary within the specified time range:
git shortlog --since="2023-01-01" --until="2023-06-30"
7. Custom output format
Customizes the output format to display the commit hash and commit message:
git shortlog --pretty=format:"%h %s"
other extensions