Skip to content

Git Mailmap Quick Reference ​

bash
# 1. Enable mailmap for current repo
git config mailmap.file .mailmap

# 2. Create/update .mailmap with canonical identities
cat >> .mailmap << 'EOF'
Canonical Name <canonical@email>  Old Name <old@email>
EOF

# 3. Verify mailmap is working
git shortlog -sne                          # mailmap-aware (capital N,E)
git shortlog -sn                           # without mailmap (lowercase n)
git log --format='%aN <%aE>' --since=1month  # mailmap-aware log

# 4. Check mailmap parsing
git check-mailmap "Old Name <old@email>"

# 5. Bootstrap mailmap from history
git log --format='%aN||%aE' --all | sort -u

# 6. CI cleanup — standardise runner identity
cat > .mailmap << EOF
CI Pipeline <ci@company.com>  <runner@$(hostname)>
CI Pipeline <ci@company.com>  <bot@users.noreply.github.com>
EOF

# 7. Blame with canonical identities
git blame --use-mailmap src/deploy.sh

# 8. Contributor roster for compliance audit
git shortlog -sne --since='2024-01-01' --until='2024-12-31'

# 9. Mailmap-aware archive (excludes personal emails from tarballs)
git archive --output=release.tar.gz HEAD

# 10. Use blob reference (mailmap outside working tree)
MAILMAP_BLOB=$(git hash-object -w .mailmap)
git config mailmap.blob "$MAILMAP_BLOB"

# Key config
git config --global mailmap.file ~/.config/git/mailmap  # global fallback
git config mailmap.file .mailmap                          # per-repo

# Mailmap format specifiers (capital = mailmap-aware)
# %aN  author name     %an  author name (raw)
# %aE  author email    %ae  author email (raw)
# %cN  committer name  %cn  committer name (raw)
# %cE  committer email %ce  committer email (raw)

Git Master — Git Reference for Every Skill Level