git shortlog command
git shortlog The command is used to generate a concise summary of commit logs, grouped by author and commit message.
git shortlog The command is mainly used to summarize the commit history of a Git repository, providing a count of commits per author and an overview of each commit category.
Basic Syntax
git shortlog [] []
: Specify the commit range for which to generate the summary; the default is all commits on the current branch.: Options for customizing the output format or behavior.
** Common options and usage:**
| Option | Description | Usage Examples |
|---|---|---|
-n or --numbered |
Sort authors by the number of commits and display each author's commit count. | git shortlog -n |
-s or --summary |
Display only authors and their commit counts, without commit messages. | git shortlog -s |
-e or --email |
Display the authors' email addresses. | git shortlog -e |
-c or --committer |
Count commits by committer rather than by author. | git shortlog -c |
-a or --all |
Include all authors (including those without any commits). | git shortlog -a |
--no-merges |
Exclude merge commits and only show 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 |
Display the commit summary in reverse order, sorted by authors' commit counts in ascending order. | git shortlog --reverse |
Common usage
1. Display commit authors and commit counts
Sort authors by the number of commits and display each author's commit count and a prefix of their commit messages:
git shortlog -n
2. Display each author's commit count
Display only authors and their commit counts, without commit messages:
git shortlog -s
3. Display an author summary including emails
Display authors and their email addresses:
git shortlog -e
4. Exclude merge commits
Exclude merge commits and only show a summary of non-merge commits:
git shortlog --no-merges
5. Count by committer
Count commits by committer rather than by author:
git shortlog -c
6. Display commits within a specific time range
Only show the commit summary within the specified time range:
git shortlog --since="2023-01-01" --until="2023-06-30"
7. Customize the output format
Customize the output format to display the commit hash and commit message:
git shortlog --pretty=format:"%h %s"
Git Basic Operations