:bulb: Use git shortlog with --since and --before to quickly audit commit activity by contributor or total count within any date range.

[01] What is git shortlog?

git shortlog summarizes git log output, grouping commits by author — ideal for generating statistics reports.

Key flags used in this post:

Flag Meaning
-s Show only the commit count (suppress commit messages)
-n Sort by number of commits, descending
-e Show author email addresses
--since Include commits after this date
--before Include commits before this date
--all Include commits from all branches
--no-merges Exclude merge commits

[02] Check Commit Authors and Counts Within a Period

1
git shortlog -sne --since={$date} --before={$date}

Example — commit count per contributor during 2022:

1
2
3
4
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>

The output is sorted by commit count (highest first) and includes each author’s email.

[03] Check the Total Commit Count Within a Period

Pipe the output through awk to sum all counts:

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

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

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

Example output:

1
2
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 — useful when you want to count only meaningful work commits.

[04] Date Format Tips

git shortlog accepts flexible date strings for --since and --before:

Format Example
Human-readable "01 Jan 2022"
ISO 8601 "2022-01-01"
Relative "6 months ago"
Last N days "30 days ago"

Use ISO 8601 format (YYYY-MM-DD) for scripting to avoid locale-dependent parsing issues.

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

[05] Notes

When sharing commit-count metrics, double-check the date range and author filter so the number reflects what you intend (per-author vs project-wide, since-when vs all-time). Combine --shortstat with wc -l for line-change totals, or pipe git log into a CSV for spreadsheet analysis. For long-running repos, prefer ISO date ranges over relative ones to keep counts reproducible.