Surgical git history rewriting: author rewrite, message scrub, sensitive data removal, and more.
Project description
🔪 git-surgeon
Surgical git history rewriting: a modular CLI toolkit wrapping git-filter-repo.
Rewrite authors, scrub sensitive data, clean commit messages, flatten merges, and filter commits, all in a single pass with automatic backup & undo.
Features
| Feature | Description |
|---|---|
| Message Scrub | Find-and-replace text in commit messages (literal or regex) |
| Blob Scrub | Remove secrets, emails, keys from file contents across all history |
| Merge Flatten | Linearize history by converting merge commits to single-parent |
| Commit Filter | Remove or keep commits matching specific criteria |
| Backup & Undo | Automatic git bundle backup + git-surgeon undo to restore |
| Dry Run | Preview every change before touching the repo |
| Interactive Wizard | Run git-surgeon with no args for guided setup |
| Config Persistence | Operations saved to .git-surgeon/config.toml (auto-gitignored) |
Quick Start
pip install git-surgeon-cli
or
uv add git-surgeon-cli
Requires Python ≥3.13 and
giton PATH.
cd /path/to/your/repo
# Option A: Interactive wizard
git-surgeon
# Option B: CLI commands
git-surgeon init
git-surgeon rewrite-authors --name "Jane" --email "jane@example.com" --default --save
git-surgeon scrub --find "secret-api-key" --replace "***REMOVED***"
git-surgeon run # creates backup, rewrites history
git-surgeon undo # restore if needed
Architecture
graph TD
classDef cli fill:#e1f5fe,stroke:#0288d1,stroke-width:2px,color:#000;
classDef core fill:#fff3e0,stroke:#f57c00,stroke-width:2px,color:#000;
classDef ops fill:#e8f5e9,stroke:#388e3c,stroke-width:2px,color:#000;
classDef ext fill:#eceff1,stroke:#607d8b,stroke-width:2px,color:#000;
U([User Input]) --> CLI[CLI & Wizard]:::cli
CLI --> Core[Engine Orchestrator]:::core
Core <--> Ops[Pluggable Operations]:::ops
Core --> GFR[git-filter-repo]:::ext
GFR --> Git[Git Repository]:::ext
For a detailed breakdown of the system architecture and data flow, see the Architecture Documentation.
Documentation
For full guides on usage, configuration, internals, and operations, please visit the Documentation Index or build the docs using MkDocs. For AI agent integration, see docs/mcp-setup.md.
WIP
Safety
Every git-surgeon run automatically creates a git bundle backup at .git-surgeon/backup.bundle before touching history.
Run git-surgeon undo to fully restore.
Use --dry-run on any command to preview without modifying anything.
License
Apache License 2.0. See LICENSE for details.
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 git_surgeon_cli-0.1.0.tar.gz.
File metadata
- Download URL: git_surgeon_cli-0.1.0.tar.gz
- Upload date:
- Size: 52.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc578a89dec42bffedd9c5306e21b2aff9149e7549a77ceb4b94fa185faa0b5b
|
|
| MD5 |
1fbc6ce29818af429595466cc468290f
|
|
| BLAKE2b-256 |
3c48b0f0939b477e9ab44c47134f4a0446ca27c8770fa46fcb1be2bb31f6882a
|
File details
Details for the file git_surgeon_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: git_surgeon_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 50.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
548c091cd38e3b7b801e6ca26a1be9534bdbb4cb27f7285d5b9ba91002b2db17
|
|
| MD5 |
2932c592e27f0e865e9d475048c001ac
|
|
| BLAKE2b-256 |
41799cfab4c8dc387376ae3cf445ae47b80356633f85eb715b4a6614d02f2a23
|