gitmailmap - Linux
Overview
gitmailmap
maps author and committer email addresses to new email addresses. It is used to clean up the history of a Git repository by replacing old email addresses with new ones. This can be useful when a developer changes their email address or when a company merges with another company.
Syntax
gitmailmap [-d] [-q] [-v <verbosity>] <old-email-1> <new-email-1>
...
Options/Flags
-d
: Dry run mode. Do not actually rewrite history.-q
: Quiet mode. Suppress output.-v <verbosity>
: Specify verbosity level. Verbosity levels are:- 0: Only show errors.
- 1: Show errors and warnings.
- 2: Show errors, warnings, and success messages.
- 3: Show errors, warnings, success messages, and debug information.
Examples
To replace the email address old@example.com
with new@example.com
, run:
gitmailmap old@example.com new@example.com
To map multiple email addresses at once, use multiple pairs of email addresses:
gitmailmap old1@example.com new1@example.com old2@example.com new2@example.com
To run in dry run mode, use the -d
option:
gitmailmap -d old@example.com new@example.com
Common Issues
One common issue that can occur is that gitmailmap
may not find all of the commits that need to be rewritten. This can happen if the commits were made by a different user or if the email address was changed in a different branch. To solve this, you can use the -d
option to see which commits would be rewritten and then manually rewrite the ones that are not.
Integration
gitmailmap
can be used with other Git commands to clean up the history of a repository. For example, you can use git rebase
to rewrite the history of a branch and then use gitmailmap
to clean up the email addresses.
Related Commands
git-filter-branch
git-rebase