git-filter-repo
$ git-filter-repo Community High RiskThe officially recommended replacement for git filter-branch and BFG Repo-Cleaner for purging large blobs, splitting subdirectories, or scrubbing leaked secrets from Git history. Refuses to rewrite non-fresh clones unless --force is supplied, protecting against accidental history corruption.
brew install git-filter-repo Streams git fast-export / fast-import locally over Git internals; impossible and unsafe to delegate to a remote MCP server.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Fully non-interactive CLI with --analyze and --dry-run, though outputs are plain text files rather than JSON.
--analyzeproduces structured text tables in.git/filter-repo/analysis/- Runs headlessly without TTY prompts
Built-in fresh-clone check blocks accidental rewrites without --force, and --dry-run previews fast-import output, though history rewriting itself is high-risk.
- Aborts on non-fresh clones unless
--forceis passed - Rewrites all commit SHAs when executed live
Single Python script installable via Homebrew, PyPI, or uvx, requiring Python 3 and Git.
- Requires
git>= 2.22 and Python 3 runtime
Orders of magnitude faster than git filter-branch for removing secrets or splitting monorepos.
- Recommended by the Git project over
git filter-branch
Maintained by core Git contributor Elijah Newren under MIT license.
- Canonical
newren/git-filter-reporepository
Extensive manpage-style documentation covering examples and safety caveats.
- Detailed
git-filter-repo.txtmanual and--help
Security, Auth & Guardrails
Operates purely on local Git repositories with no credentials stored or required.
MIT open-source Python tool; completely free.
# git-filter-repo Agent Rules - NEVER run `git-filter-repo --force` on a primary working checkout; always work on a dedicated fresh `git clone`. - Run `git-filter-repo --analyze` and `--dry-run` first to verify target paths before rewriting refs.
Agent-Ready Command Recipes
Safe Read-Only Queries
git-filter-repo --analyze
Generates .git/filter-repo/analysis/ reports summarizing large paths and blobs without rewriting history.
Controlled Writes & Previews
git-filter-repo --invert-paths --path secrets.env --dry-run
Writes the proposed fast-import stream to .git/filter-repo/fast-export.filtered without mutating branches or tags.
Strengths for Agents
- + Refuses to run on dirty or non-fresh clones without explicit
--force, preventing common user errors. - +
--analyzeidentifies bloated blobs and directories without modifying the repository. - + Far faster and safer than legacy
git filter-branch.
Caveats & Pitfalls
- ! Rewrites commit hashes across the entire repository, requiring coordinated force-pushes.
- ! Output and analysis reports are plain text rather than JSON.