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. <[email protected]>
John Doe <[email protected]>
John H. Doe <[email protected]>

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 <[email protected]> Johhny Doe <[email protected]>
JD <[email protected]> John <[email protected]>

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 <[email protected]> <[email protected]>

To see all authors for a repo use:

git shortlog --summary --numbered --email

This way you can map authors properly.