A powerful, production-grade CLI tool to safely rewrite Git commit authors and committers across your repository history.
- 🔄 Flexible Rewriting: Change specific authors or rewrite all commits
- 🔍 Author Detection: Identify all unique authors in your repository
- 🧪 Dry Run Mode: Preview changes before applying them
- 💾 Automatic Backups: Create repository backups before rewriting
- ⚡ Two Backends: Uses
git filter-repo(preferred) withgit filter-branchfallback - 🛡️ Safety First: Validates repo state and provides clear warnings
- 📝 Preserves History: Keeps commit messages, timestamps, and commit order intact
- 🌍 Cross-Platform: Works on macOS, Linux, and Windows
pip install gitauthgit clone https://github.com/mubashardev/gitauth.git
cd gitauth
pip install -e .For best performance, install git-filter-repo:
# macOS
brew install git-filter-repo
# Linux (Debian/Ubuntu)
sudo apt-get install git-filter-repo
# Or via pip
pip install git-filter-repoIf not installed, gitauth will automatically fall back to git filter-branch.
List all unique authors in your repository:
gitauth checkOutput:
Found 3 unique authors:
John Doe <[email protected]>
Jane Smith <[email protected]>
Old Name <[email protected]>
See which commits would be changed without modifying anything:
# Preview changes for a specific email
gitauth dry-run --old-email "[email protected]"
# Preview changes for a specific name
gitauth dry-run --old-name "Old Name"Change commits from a specific author:
# By email
gitauth rewrite --old-email "[email protected]" --new-name "New Name" --new-email "[email protected]"
# By name
gitauth rewrite --old-name "Old Name" --new-name "New Name" --new-email "[email protected]"
# Both (more specific)
gitauth rewrite --old-email "[email protected]" --old-name "Old Name" --new-name "New Name" --new-email "[email protected]"Change all commits to a new author:
gitauth rewrite --all --new-name "New Name" --new-email "[email protected]"Manually create a backup of your repository:
gitauth backupCreates: backup-YYYYMMDD-HHMMSS.tar.gz
After rewriting, push to remote (use with caution!):
# Interactive confirmation
gitauth push
# Force push without confirmation
gitauth push --forceAdd --verbose to any command for detailed output:
gitauth rewrite --old-email "[email protected]" --new-name "New Name" --new-email "[email protected]" --verboseFilter operations by specific branch:
# Check authors only on main branch
gitauth check --branch main
# Preview commits from specific branch
gitauth dry-run --old-email "[email protected]" --branch develop
# Interactive selection for a specific branch
gitauth dry-run --choose-old --branch feature/new-featureNote: The --branch option filters which commits are analyzed and displayed. When using the rewrite command, git-filter-repo and git-filter-branch rewrite history across all branches by default (this is standard Git behavior for history rewriting tools).
Rewriting Git history is a destructive operation. Before using this tool:
- ✅ Always create a backup (or work on a clone)
- ✅ Coordinate with your team if working on a shared repository
- ✅ Understand the implications of force-pushing
- ✅ Test on a branch first before affecting main/master
After rewriting history, you'll need to force push:
git push --force-with-lease origin main
# or use: gitauth push --forceWarning: This will rewrite history on the remote. All collaborators must re-clone or reset their local repositories.
You accidentally committed with your work email and want to change it to personal:
# 1. Check current authors
gitauth check
# 2. Preview changes
gitauth dry-run --old-email "[email protected]"
# 3. Rewrite commits
gitauth rewrite --old-email "[email protected]" --new-name "Your Name" --new-email "[email protected]"
# 4. Push changes
gitauth pushYou committed with different names/emails and want to unify them:
# Fix first identity
gitauth rewrite --old-email "[email protected]" --new-name "Your Name" --new-email "[email protected]"
# Fix second identity
gitauth rewrite --old-email "[email protected]" --new-name "Your Name" --new-email "[email protected]"
# Push once
gitauth pushChange all commits to a new author (e.g., transferring project ownership):
# Preview all commits
gitauth dry-run --all
# Rewrite all
gitauth rewrite --all --new-name "New Owner" --new-email "[email protected]"
# Push
gitauth push- Detection: Scans repository using
git logto find commits matching criteria - Validation: Checks if repository is clean and valid
- Backup: Optionally creates a compressed backup
- Rewriting: Uses
git filter-repo(fast) orgit filter-branch(fallback) - Preservation: Maintains commit timestamps, messages, and tree structure
- Safety: Provides dry-run mode and interactive confirmations
gitauth/
├── gitauth/
│ ├── __init__.py
│ ├── cli.py # Typer CLI interface
│ └── core/
│ ├── __init__.py
│ ├── git_utils.py # Git operations and validation
│ ├── detect.py # Author detection
│ ├── backup.py # Backup functionality
│ └── rewrite.py # Rewrite logic (filter-repo/filter-branch)
├── tests/
│ ├── __init__.py
│ ├── test_git_utils.py
│ ├── test_detect.py
│ ├── test_backup.py
│ └── test_rewrite.py
├── pyproject.toml
├── README.md
└── LICENSE
git clone https://github.com/yourusername/gitauth.git
cd gitauth
pip install -e ".[dev]"pytest
pytest --cov=gitauth tests/black gitauth tests
ruff check gitauth testspython -m buildpython -m twine upload dist/*- Python 3.8+
- Git 2.0+
git-filter-repo(optional, recommended)
MIT License - see LICENSE file for details.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
- Initial release
- Support for
git filter-repoandgit filter-branch - Dry run mode
- Automatic backups
- Author detection
- Cross-platform support
- Inspired by GitHub's author-rewrite script
- Powered by git-filter-repo
- Built with Typer
Made with ❤️ by Mubashar Dev