LinuxCommandLibrary

git-shortlog

Summarize git commit history

TLDR

View a summary of all the commits made, grouped alphabetically by author name

$ git shortlog
copy

View a summary of all the commits made, sorted by the number of commits made
$ git shortlog [[-n|--numbered]]
copy

View a summary of all the commits made, grouped by the committer identities (name and email)
$ git shortlog [[-c|--committer]]
copy

View a summary of the last 5 commits (i.e. specify a revision range)
$ git shortlog HEAD~5..HEAD
copy

View all users, emails and the number of commits in the current branch
$ git shortlog [[-s|--summary]] [[-n|--numbered]] [[-e|--email]]
copy

View all users, emails and the number of commits in all branches
$ git shortlog [[-s|--summary]] [[-n|--numbered]] [[-e|--email]] --all
copy

SYNOPSIS

git shortlog [] [] [[--] ...]

PARAMETERS

-n, --numbered
    Show the number of commits next to the author's name.

-s, --summary
    Suppress commit descriptions and show only author names and commit counts.

-e, --email
    Show the author's email address alongside their name.

-w[width], --wrap[=width]
    Wrap the second line of the commit description to a specified width (default 76). The width argument is optional.

-c, --committer
    Group commits by committer instead of author.

--no-merges
    Do not list merge commits.

--sort=
    Sort authors by key. Valid keys include: name (default), email, committerdate, authordate, or commits.

-i, --ignore-case
    Ignore case when sorting or filtering authors.


    Limit the commits to the specified range (e.g., HEAD~5..HEAD, v1.0..master).

-- ...
    Limit the commits to those that affect the specified paths. Use -- to separate paths from revisions.

DESCRIPTION

git shortlog is a Git command that provides a concise summary of git log output, primarily used for generating release notes or changelogs.

Unlike git log, which displays individual commit details chronologically, git shortlog groups commits by author, presenting each author's contributions followed by a brief summary of their respective commit messages. This makes it incredibly useful for quickly seeing who contributed what and how much, within a specified revision range.

By default, authors are sorted alphabetically, and each commit message is displayed on a new line. It supports various options to customize the output, such as showing the number of commits per author (-n), suppressing individual commit messages to show only author names and counts (-s), including email addresses (-e), or sorting authors by their commit count rather than alphabetically (--sort=commits). It can also filter commits by date, author, or message content, similar to git log. This command is invaluable for understanding team contributions and generating high-level project summaries.

CAVEATS

By default, git shortlog only considers authors and not committers, unless the -c or --committer option is used.
The command's output is optimized for human readability, making it less suitable for direct scripting unless parsing for specific patterns.
Sorting by date (--sort=committerdate or --sort=authordate) sorts authors by the date of their first commit, not their last or most recent commit, which might lead to unexpected ordering if not understood.

OUTPUT FORMAT

By default, git shortlog outputs a header with the author's name (and optional email/count), followed by a list of their commit messages. Each commit message is typically truncated to its first line.

DEFAULT RANGE

Without specifying a , git shortlog processes all commits reachable from HEAD.

INTEGRATION WITH GIT LOG

Many options accepted by git log (like --since, --until, --grep, --author) are also accepted by git shortlog to filter the set of commits before summarization.

HISTORY

git shortlog has been a core utility within Git since its early days, designed to provide a quick and meaningful overview of project contributions. Its fundamental purpose of summarizing commit history by author has remained consistent. It evolved alongside Git's logging capabilities, inheriting and enhancing options for filtering and formatting commit information. Its simplicity and effectiveness for generating changelogs or team contribution reports quickly made it a widely used command for project managers and developers alike.

SEE ALSO

Copied to clipboard