Analyzing Commit History with Git Shortlog

So far in this Git series, we’ve explored merges and rebases. In this blog, let’s step into something lighter but very powerful for project statistics — the git shortlog command.

This command helps you summarize commit history grouped by author, making it perfect for team projects where multiple developers contribute.


Running Git Shortlog

In your project folder (for example project6), run:

git shortlog

Output:

Gaurav Sharma (12):
    Initial commit
    Add feature step 1
    Add feature step 2
    Add feature step 3
    Add config file
    ...

If multiple developers worked on the repository, you’d see their names one by one with their commit lists.


Sorting Authors by Number of Commits

You can sort the summary so that the author with the most commits appears at the top:

git shortlog -n

Output:

Gaurav Sharma (12)
Sourav Sharma (5)
Alice Johnson (3)

Here, -n sorts by commit count in descending order.


Showing Email Addresses

To also display email addresses of authors:

git shortlog -e

Output:

Gaurav Sharma <gsharma@example.com> (12)
Sourav Sharma <ssh@example.com> (5)

This is useful for tracking contributions by specific email identities.


Showing Only Commit Counts

If you don’t want commit messages, just counts per author:

git shortlog -s

Output:

12  Gaurav Sharma
 5  Sourav Sharma

This quickly shows how many commits each author has contributed.


Combining Options

You can also combine options, for example:

git shortlog -sne

This will show commit counts, sorted, with email addresses.


Summary

  • git shortlog groups commits by author.
  • Use -n to sort by number of commits.
  • Use -e to include email addresses.
  • Use -s for summary (counts only).
  • Great for team projects to analyze contributor statistics.

Keep Learning 🚀

👉 Subscribe to Learning Ocean – Subscribers get coupon codes for my courses, early access to blogs and courses, and even exclusive YouTube videos.

👉 My YouTube Channel – More videos, more fun, and lots of learning!

👉 📺 Watch this topic in video form

Stay curious, keep coding, and let’s make learning fun together! 🎉