DeepGraph
All posts

Count Git commits per author across emails

5 November 2026 · The DeepGraph team

To count commits per author in one Git project, run git shortlog -sne HEAD. It lists every author with their number of commits, most first. The catch is that Git counts by name and email, so one person who committed from a work address and a home address shows up twice. This guide shows the commands, how to fix the doubles with a .mailmap file, and how to get the same totals across many projects with DeepGraph, a Git contributor analytics app.

Count commits per author with git shortlog

Inside the project folder, run:

  • git shortlog -sne HEAD lists commit counts with each author's name and email, highest first.
  • git shortlog -sn --no-merges HEAD leaves out merge commits, which often only join branches.
  • git shortlog -sne --since=2026-01-01 HEAD counts only commits since a date.

The -s flag prints a count instead of every commit message, -n sorts by that count, and -e adds the email. Naming HEAD makes the command read the history even when it runs in a script.

Count lines added and removed per author

Commit counts say how often someone saved work, not how big it was. For lines, ask git log for numbers:

  • git log --author="Ada" --no-merges --numstat --pretty=tformat: prints, for every commit by Ada, the lines added and removed in each file.

Add up the first two columns to get Ada's lines added and removed. Lines are a rough measure: a renamed folder or a generated file can add thousands of lines in one commit, so look at the commits behind a big number before you trust it.

Why one person shows up under several emails

Git stores the name and email that were set on the computer that made each commit. The same person often has:

  • a work address and a personal address,
  • a typo or an old spelling of their name,
  • a GitHub noreply address, used when they edit a file on GitHub or keep their email private,
  • a different name on a new laptop.

git shortlog counts each name and email pair on its own, so their work is split between two or more lines, and none of them shows their real total.

Join the doubles with a .mailmap file

Git has a built-in fix: a file named .mailmap at the top of the project. Each line maps an address someone used to the name and address you want to see. For example:

  • Ada Lovelace <ada@example.com> <ada@home.example> shows commits made as ada@home.example under Ada Lovelace and ada@example.com.

git shortlog reads .mailmap on its own, and git log uses it with --use-mailmap. Run git shortlog -sne HEAD again and Ada appears once, with all her commits.

Where .mailmap gets hard

.mailmap works well for one project with a few people. It gets harder when:

  • You have many projects. Each one needs its own .mailmap, and the files drift apart.
  • People join all the time. Someone has to notice each new address and add a line.
  • Bots commit too. Dependency bots and release scripts show up as authors, and you have to leave them out by hand.
  • You need the totals over time. shortlog prints one number, not a chart of busy and quiet weeks.

Commits per author across projects with DeepGraph

DeepGraph reads the history of your GitHub, GitLab (gitlab.com), Bitbucket (bitbucket.org), or local Git projects and shows one profile per person, with their commits, lines added, lines removed, and files changed.

One person who committed from a work and a home address, shown once. Open the addresses to see what each one did.
  • It joins the clear cases. Names and emails that clearly belong to the same person, such as the same email or a GitHub noreply address with the same username, become one profile.
  • You decide the rest. Join two profiles you know are the same person, or split ones that are not. DeepGraph keeps your choices, and a similar name alone is never enough to join two people.
  • You leave out bots. Exclude bots and automated accounts from the report, and the totals leave them out.
  • It works across projects. Put projects in a folder and see each person's totals over all of them, with a chart of their work over time.

DeepGraph does not read your .mailmap file; it joins profiles on its own and keeps your manual joins. Your Git history and your .mailmap stay unchanged.

The people of a sample web shop, busiest first, each with their totals and a small chart of their work.

Use the numbers to understand, not to rank

Commit and line counts describe activity, not how good or how hard the work was. A careful fix may be one line; a generated file may be thousands. Use per-author totals to find who knows a part of the code, to welcome a new teammate, or to see who worked on a release, and read them next to the commits behind them.

Try it

Open a sample report on the DeepGraph home page, no account needed, or paste a link to a public project. Read more about Git contributor stats with one profile per person, analyzing a local Git project, or follow the Getting started guide.