This tool helps you scrub and replace Git user information in a repository's history using Git's mailmap feature. It's useful for consolidating multiple author identities or updating author information across the entire repository history.
- Python 3.x
- Git
- git-filter-repo (required for rewriting Git history)
On Windows (using pip):
pip install git-filter-repo
On Linux/macOS:
# Using pip
pip install git-filter-repo
# Or using package manager
# Ubuntu/Debian:
sudo apt-get install git-filter-repo
# macOS (Homebrew):
brew install git-filter-repo
- Run the script:
python git_user_scrubber.py
-
When prompted:
- Enter the path to the Git repository (or press Enter for current directory)
- Enter the target author name (the name you want to use for replacement)
- Enter the target email (the email you want to use for replacement)
-
The script will:
- Display a list of all unique authors in the repository
- Allow you to select which authors to replace (by entering their numbers, comma-separated)
- Show you the mailmap entries that will be created
- Ask for confirmation before applying changes
-
After confirmation, the script will:
- Create a .mailmap file
- Apply the changes using git-filter-repo
- Clean up temporary files
Git User Scrubber
================
Enter the path to the git repository [.]: /path/to/repo
Enter the target author name: John Doe
Enter the target email: [email protected]
Current authors in repository:
1. John Smith <[email protected]>
2. J. Smith <[email protected]>
3. John Doe <[email protected]>
Enter the numbers of authors to replace (comma-separated), 'a' to apply changes, or 'q' to quit: 1,2
- This script will rewrite Git history, so make sure to:
- Back up your repository before running the script
- Push changes to a new branch first
- Inform team members about the upcoming history rewrite
- The changes are permanent and will affect all commits in the repository
- You may need to force push the changes to remote repositories
- Make sure you have the necessary permissions to rewrite repository history
- The script requires explicit confirmation before applying changes
- It shows you the exact mailmap entries that will be created
- It validates the Git repository path before proceeding
- It handles errors gracefully and provides clear error messages
If you encounter any issues:
- Make sure git-filter-repo is installed correctly
- Verify you have write permissions in the repository
- Check that the repository path is correct
- Ensure you're not in a detached HEAD state
- Make sure you have no uncommitted changes
This script is provided as-is. Use at your own risk.