:bulb: This note explains how to inspect Git commit results within a specific time range.

[01] shortlog

A command that provides a summarized view of git log output.

[02] Check Commit Authors and Counts Within a Period

1
2
3
4
5
6
7
git shortlog -sne --since={$date} --before={$date}

# ex) commit count per contributor during 2022
root@master:~/tools# git shortlog -sne --since="01 Jan 2022" --before="30 Dec 2022"
   198  aaa <aaa@naver.com>
    65  bbb <bbb@naver.com>
    48  ccc <ccc@naver.com>

[03] Check the Total Commit Count Within a Period

Combine with the awk command.

1
2
3
4
5
6
7
8
9
10
11
12
# current branch
git shortlog -sne --since={$date} --before={$date} | awk '{sum += $1} END {print sum}'

# all branch
git shortlog --all -sne --since="01 Jan 2022" --before="30 Dec 2022" | awk '{sum += $1} END {print sum}'

# without merge commit
git shortlog --all --no-merges -sne --since="01 Jan 2022" --before="30 Dec 2022" | awk '{sum += $1} END {print sum}'

# ex) total commit count during 2022
root@master:~/tools# git shortlog -sne --since="01 Jan 2022" --before="30 Dec 2022" | awk '{sum += $1} END {print sum}'
311
  • --all pulls log information from all branches in the current repository.
  • --no-merges excludes commits created by merging between branches.

:small_blue_diamond:Reference: Git-shortlog :small_blue_diamond:Reference: Git number of commits per author on all branches