Git Mailmap

I’m mostly working with PHP and for this I’m using PhpStorm - best IDE for php development, at least when using a framework like Laravel.
When inspecting code, if you’re like me and see something fishy, first thing I do is to check annotations (right click on the line numbers and click “Annotate”), so I can see how worked on that part of the code - this is also a shortcut to see git history, since if you click on the annotation, it will show you the git history.

The names displayed in the annotations can be sometimes confusing:

For example an author might use these formats:

John D. <john@mail.com>
John Doe <john.doe@mail.com>
John H. Doe <johnny@mail.com>

To map all these under a single format, we can use git mailmap, which is a configuration file that maps different author names to to a single one.
To do this create a new file in the root of the git repo named .mailmap
In there on each line set how you’d like to map different accounts as follows:

JD <john.doe@mail.com> Johhny Doe <johnny.doe@mail.com>
JD <john.doe@mail.com> John <john.doe@mail.com>

The above will replace both the author name and email. If you’d like to replace only the email then use this format:

Author Name <author@mail.com> <commiter@mail.com>

To see all authors for a repo use:

git shortlog --summary --numbered --email

This way you can map authors properly.