Skip to content

danwize/git-user-scrubber

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Git User Scrubber

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.

Prerequisites

  • Python 3.x
  • Git
  • git-filter-repo (required for rewriting Git history)

Installation

Installing git-filter-repo

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

Usage

  1. Run the script:
python git_user_scrubber.py
  1. 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)
  2. 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
  3. After confirmation, the script will:

    • Create a .mailmap file
    • Apply the changes using git-filter-repo
    • Clean up temporary files

Example

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

Important Notes

  • 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

Safety Features

  • 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

Troubleshooting

If you encounter any issues:

  1. Make sure git-filter-repo is installed correctly
  2. Verify you have write permissions in the repository
  3. Check that the repository path is correct
  4. Ensure you're not in a detached HEAD state
  5. Make sure you have no uncommitted changes

License

This script is provided as-is. Use at your own risk.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages