Skip to main content

🔪 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
Watermark & Detect Rewritten commits carry a Rewritten-With: git-surgeon trailer; git-surgeon detect finds them (--no-watermark to skip)
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)

Usage Instructions

pip install git-surgeon-cli

or

uv add git-surgeon-cli

Requires Python ≥3.12 and git on 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.

About

License

Apache License 2.0. See LICENSE for details.

Pypi

PyPI version Python versions

Metadata

Release files for git-surgeon-cli 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for git-surgeon-cli 0.2.0
File Size Uploaded Provenance
git_surgeon_cli-0.2.0.tar.gz 65.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for git-surgeon-cli 0.2.0
File Interpreter ABI Platform
git_surgeon_cli-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 130.3 kB

Release files / git_surgeon_cli-0.2.0.tar.gz

Download URL git_surgeon_cli-0.2.0.tar.gz
Size 65.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ec00601dc2e5cb70977d6381f845eedd9b0b091288b68fd525b7a3aaa8bc8161
BLAKE2b-256 checksum
How to use checksums
fedb5cdfd34f61a4e94d4cf13419ef9b8b1e38c6c7251b248d092716f056ef5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","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}

Release files / git_surgeon_cli-0.2.0-py3-none-any.whl

Download URL git_surgeon_cli-0.2.0-py3-none-any.whl
Size 64.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
80eef1df9dac907ae3ecd97968af13706032a1027538a41aa28efe54c35897c3
BLAKE2b-256 checksum
How to use checksums
54f837fa85936a4367bd8eb7a3f02b81ec9afd11d7410dadaa34ed1ec107cc04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","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}

Security for git-surgeon-cli 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page