首頁·終端機命令

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