Git statistics

Commits per user

git shortlog -s -n

This command lists commits per user in the current branch. For example.

118  Jennifer Hunt
29 Nicholas Zielinski
19 Kimberly Bell

You can allso add the flags

  • --all To include commits from all branches
  • --no-merges To exluce merge commits
  • --since="22 Aug 2021" --before="01 Sept 2021" To specify time period

Git commits per day

git log --date=short --pretty=format:%ad | uniq -c

Displays a list of commits per day. For example.

21 2021-12-21
12 2021-12-20
26 2021-12-17
15 2021-12-16
13 2021-12-15

If you would like the list reversed, add the sort command sort

git log --date=short --pretty=format:%ad | sort | uniq -c
13 2021-12-15
15 2021-12-16
26 2021-12-17
12 2021-12-20
21 2021-12-21

Oldest commit in repo

To find the first commit in a repo.

git log --reverse -n 1

or

git log --reverse

Empty commit

To add an empty commit. For example, to trigger a deploy.

git commit --allow-empty -m "Trigger deploy"