Skip to main content
Chapter 21 of 61 · 1 sections · Page 100

Git: Mailmap & Aliases

Map author names and email aliases in .mailmap to deduplicate contributor statistics in git shortlog.

Original chapter reference: Chapter 21: .mailmap file: Associating contributor and email aliases. The command options and documentation recipes below are fully transcribed from Git Notes for Professionals.

Section 21.1: Merge contributers by aliases to show commit count in shortlog

When contributors add to a project from different machines or operating systems, it may happen that they use different email addresses or names for this, which will fragment contributor lists and statistics.

Running git shortlog -sn to get a list of contributors and the number of commits by them could result in the following output:

Source example · PDF page 100
Patrick Rothfuss 871
Elizabeth Moon 762
E. Moon 184
Rothfuss, Patrick 90

This fragmentation/disassociation may be adjusted by providing a plain text file .mailmap, containing email mappings.

All names and email addresses listed in one line will be associated to the first named entity respectively.

For the example above, a mapping could look like this:

Source example · PDF page 100
Patrick Rothfuss <fussy@kingkiller.com> Rothfuss, Patrick <fussy@kingkiller.com>
Elizabeth Moon <emoon@marines.mil> E. Moon <emoon@scifi.org>

Once this file exists in the project's root, running git shortlog -sn again will result in a condensed list:

Source example · PDF page 100
Patrick Rothfuss 961
Elizabeth Moon 946
Buy me a coffee
Daily Practice
0/0