Q: What is `.mailmap` and when would you use it?
.mailmap is a file that maps different author names and emails to a canonical identity. It fixes inconsistencies in git log, git shortlog...
🛠️ Production Runbook & Step-by-Step Resolution
Initial Diagnostics & Root Cause Analysis
.mailmap is a file that maps different author names and emails to a canonical identity. It fixes inconsistencies in git log, git shortlog, and git blame without rewriting history.
- Open-source projects where contributors use different emails (work vs personal).
- Post-acquisition consolidation (merging email domains).
- Correcting typos in historical author names.
Remediation & Permanent Safeguards
The problem: over time, the same person commits with different identities: The solution — .mailmap in the repo root: Format: Canonical Name After adding this file, git shortlog -sne and git log --format='%aN' consolidate all entries under the canonical identity. git blame also uses it. Use cases: The .mailmap file should be committed to the repo. It doesn't change any commit objects — it's a display-time mapping only. --- ## 🔶 Git Configuration & Optimization
Alice Smith <alice@company.com>
Alice <alice@personal.com>
A. Smith <asmith@oldcompany.com>
git shortlog -snefor accurate contribution statistics.
- Open-source projects where contributors use different emails (work vs personal).
- Post-acquisition consolidation (merging email domains).
- Correcting typos in historical author names.