首页·终端命令

git shortlog

git

用法

git shortlog -sne [<revision-range>]

按作者把提交分组计数,写发布说明很方便;同一个人用了两个邮箱时,除非用 .mailmap 归并,否则会被算成两个人。

常用选项

选项含义
-scounts only, no subjects
-nsort by number of commits
-eshow the email address as well
-cgroup by committer instead of author
--no-mergesleave merge commits out of the count
--since=<date>only commits after a date

示例

git shortlog -sne

every contributor with a commit count

git shortlog -sn v1.1.0..v1.2.0

who did what between two releases

git shortlog --no-merges -sn --since="1 year ago"

this year, merges excluded

难的地方在于撤销有好几种:把分支的指向挪走,和补一个反向提交,不是一回事。

怎么看

  • 方括号 [ ] 表示这部分可以不写。
  • 省略号 … 表示可以写多个。
  • 选项区分大小写——有些命令里 -r 和 -R 不是一回事。

常见问题

Q. git shortlog 是做什么的?

按作者把提交分组计数,写发布说明很方便;同一个人用了两个邮箱时,除非用 .mailmap 归并,否则会被算成两个人。

Q. 怎么写?

git shortlog -sne [<revision-range>] —— 方括号表示可以省略的部分。

Q. 值得记的选项有几个?

这里列了 6 个,完整列表在 man git。这条命令属于git。

相关命令

man 手册: man git-shortlog