git shortlog 命令

Git 基本操作


git shortlog 命令用于生成简洁的提交日志摘要,按作者和提交消息进行归类。

git shortlog 命令主要用于总结 Git 仓库的提交历史,提供对每位作者的提交计数以及每个提交类别的概览。

基本语法

git shortlog [] []
  • :指定要生成摘要的提交范围,默认为当前分支的全部提交。
  • :用于定制输出格式或行为的选项。


常用选项和用法:

选项 说明 用法示例
-n--numbered 按提交数量对作者进行排序,显示每个作者的提交数量。 git shortlog -n
-s--summary 仅显示作者及其提交数量,不显示提交信息。 git shortlog -s
-e--email 显示作者的电子邮件地址。 git shortlog -e
-c--committer 按提交者(committer)统计提交数量,而不是作者(author)。 git shortlog -c
-a--all 包括所有作者(包括那些没有任何提交的作者)。 git shortlog -a
--no-merges 排除合并提交,只显示非合并提交的摘要。 git shortlog --no-merges
--pretty 自定义输出格式。 git shortlog --pretty=format:"%h %s"
--since 仅显示指定时间范围内的提交。 git shortlog --since="2023-01-01"
--until 仅显示指定时间之前的提交。 git shortlog --until="2023-01-01"
--reverse 逆序显示提交摘要,按作者提交数量的升序排列。 git shortlog --reverse

常见用法

1、显示提交作者和提交数量

按提交数量对作者进行排序,显示每个作者的提交数量及其提交消息的前缀:

git shortlog -n

2、显示每个作者的提交数量

仅显示作者及其提交数量,不显示提交信息:

git shortlog -s

3、显示包括电子邮件的作者摘要

显示作者及其电子邮件地址:

git shortlog -e

4、排除合并提交

排除合并提交,仅显示非合并提交的摘要:

git shortlog --no-merges

5、按提交者统计

按提交者(committer)统计提交数量,而不是作者(author):

git shortlog -c

6、显示特定时间范围内的提交

仅显示指定时间范围内的提交摘要:

git shortlog --since="2023-01-01" --until="2023-06-30"

7、自定义输出格式

自定义输出格式,以显示提交哈希和提交信息:

git shortlog --pretty=format:"%h %s"

Git 基本操作

本文来源于互联网:git shortlog 命令