git shortlog command

Git Basic Operations


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:

OptionsDescriptionUsageExample
-nor--numberedSorts authors by commit count, showing the number of commits for each author.git shortlog -n
-sor--summaryShows only authors and their commit counts, without displaying commit messages.git shortlog -s
-eor--emailDisplay the author's email address.git shortlog -e
-cor--committerCounts commits by committer rather than by author.git shortlog -c
-aor--allIncludes all authors (including those with no commits).git shortlog -a
--no-mergesExcludes merge commits, showing only a summary of non-merge commits.git shortlog --no-merges
--prettyCustomize the output format.git shortlog --pretty=format:"%h %s"
--sinceOnly show commits within the specified time range.git shortlog --since="2023-01-01"
--untilOnly show commits before the specified time.git shortlog --until="2023-01-01"
--reverseDisplays 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"

Git Basic Operations

other extensions