A CLI tool to rewrite Git commit authors and committers
Project description
GitAuth
A powerful, production-grade CLI tool to safely rewrite Git commit authors and committers across your repository history.
Features
- ๐ 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
Installation
From PyPI
pip install gitauth
From Source
git clone https://github.com/mubashardev/gitauth.git
cd gitauth
pip install -e .
Optional: Install git-filter-repo
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-repo
If not installed, gitauth will automatically fall back to git filter-branch.
Usage
Check Repository Authors
List all unique authors in your repository:
gitauth check
Output:
Found 3 unique authors:
John Doe <john@example.com>
Jane Smith <jane@example.com>
Old Name <old@dev.com>
Dry Run (Preview Changes)
See which commits would be changed without modifying anything:
# Preview changes for a specific email
gitauth dry-run --old-email "old@dev.com"
# Preview changes for a specific name
gitauth dry-run --old-name "Old Name"
Rewrite Specific Author
Change commits from a specific author:
# By email
gitauth rewrite --old-email "old@dev.com" --new-name "New Name" --new-email "new@dev.com"
# By name
gitauth rewrite --old-name "Old Name" --new-name "New Name" --new-email "new@dev.com"
# Both (more specific)
gitauth rewrite --old-email "old@dev.com" --old-name "Old Name" --new-name "New Name" --new-email "new@dev.com"
Rewrite All Commits
Change all commits to a new author:
gitauth rewrite --all --new-name "New Name" --new-email "new@dev.com"
Create Backup
Manually create a backup of your repository:
gitauth backup
Creates: backup-YYYYMMDD-HHMMSS.tar.gz
Push Changes
After rewriting, push to remote (use with caution!):
# Interactive confirmation
gitauth push
# Force push without confirmation
gitauth push --force
Enable Verbose Logging
Add --verbose to any command for detailed output:
gitauth rewrite --old-email "old@dev.com" --new-name "New Name" --new-email "new@dev.com" --verbose
โ ๏ธ Important Warnings
History Rewriting
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
Force Pushing
After rewriting history, you'll need to force push:
git push --force-with-lease origin main
# or use: gitauth push --force
Warning: This will rewrite history on the remote. All collaborators must re-clone or reset their local repositories.
Examples
Example 1: Fix Personal Email
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 "work@company.com"
# 3. Rewrite commits
gitauth rewrite --old-email "work@company.com" --new-name "Your Name" --new-email "personal@gmail.com"
# 4. Push changes
gitauth push
Example 2: Unify Multiple Identities
You committed with different names/emails and want to unify them:
# Fix first identity
gitauth rewrite --old-email "old1@example.com" --new-name "Your Name" --new-email "unified@example.com"
# Fix second identity
gitauth rewrite --old-email "old2@example.com" --new-name "Your Name" --new-email "unified@example.com"
# Push once
gitauth push
Example 3: Transfer Repository Ownership
Change 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 "newowner@example.com"
# Push
gitauth push
How It Works
- 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
Project Structure
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
Development
Setup Development Environment
git clone https://github.com/yourusername/gitauth.git
cd gitauth
pip install -e ".[dev]"
Run Tests
pytest
pytest --cov=gitauth tests/
Format Code
black gitauth tests
ruff check gitauth tests
Build Package
python -m build
Publish to PyPI
python -m twine upload dist/*
Requirements
- Python 3.8+
- Git 2.0+
git-filter-repo(optional, recommended)
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
Changelog
Version 1.0.0
- Initial release
- Support for
git filter-repoandgit filter-branch - Dry run mode
- Automatic backups
- Author detection
- Cross-platform support
Support
- ๐ Report bugs
- ๐ก Request features
- ๐ Read documentation
Acknowledgments
- Inspired by GitHub's author-rewrite script
- Powered by git-filter-repo
- Built with Typer
Made with โค๏ธ by Mubashar Dev
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gitauth-1.0.0.tar.gz.
File metadata
- Download URL: gitauth-1.0.0.tar.gz
- Upload date:
- Size: 22.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42ab574c4c2745997a0ed629bacc4cd66055630b058de56a9947539d81addbd7
|
|
| MD5 |
12f4904063c308c2111d4ecc5c895de8
|
|
| BLAKE2b-256 |
83d56845cea77b9a58ef733f8fa61420981835b8ddec4fa2737f29bbd9de1866
|
File details
Details for the file gitauth-1.0.0-py3-none-any.whl.
File metadata
- Download URL: gitauth-1.0.0-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2957fa074e3b07fb11f80f6a99413dfa95a04bade7351929f40b990dd1f1ec8e
|
|
| MD5 |
7180c311ac4a27c785046961077fb7c0
|
|
| BLAKE2b-256 |
e8108308afe65fba736ce14ee4a841648be1f79410b012cfe713b9440b1bf204
|