Skip to content

πŸ¦€ A high-performance Rust implementation of git-filter-repo for efficiently rewriting Git repository history. Remove sensitive data, shrink repos, and restructure projects with streaming pipeline architecture.

License

Notifications You must be signed in to change notification settings

Cactusinhand/filter-repo-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

filter-repo-rs

English | δΈ­ζ–‡

πŸ¦€ Fast, safe Git history rewriting in Rust β€” remove secrets, slim repos, restructure paths.

What Problems Does It Solve?

😱 Your Problem βœ… One Command
Leaked API keys/tokens in history filter-repo-rs --replace-text secrets.txt --sensitive
Repo too large, clone takes forever filter-repo-rs --max-blob-size 10M
Need to extract subdirectory as new repo filter-repo-rs --subdirectory-filter frontend
Bulk rename tags/branches filter-repo-rs --tag-rename v1.:legacy/v1.
Remove specific file from all history filter-repo-rs --path docs/secret.md --invert-paths
Analyze repo health filter-repo-rs --analyze

Quick Examples

Remove Leaked Secrets

# 1. Backup first (strongly recommended)
filter-repo-rs --backup

# 2. Create replacement rules (secrets.txt)
#    API_KEY_12345==>REDACTED
#    regex:password\s*=\s*"[^"]+==>[REMOVED]

# 3. Clean all history
filter-repo-rs --replace-text secrets.txt --sensitive --write-report

# 4. Force push
git push --force --all && git push --force --tags

Slim Down Bloated Repo

# Analyze first
filter-repo-rs --analyze

# Remove files larger than 10MB
filter-repo-rs --max-blob-size 10M --write-report

Restructure Paths

# Extract subdirectory as new root
filter-repo-rs --subdirectory-filter src/frontend

# Move root into subdirectory
filter-repo-rs --to-subdirectory-filter packages/core

# Bulk rename paths
filter-repo-rs --path-rename old/:new/

Safety First

Flag Purpose
--backup Create timestamped bundle before rewriting
--dry-run Preview changes without modifying anything
--write-report Generate audit report of all changes
--sensitive Cover all refs including remotes

Installation

Requirements: Git on PATH, Rust toolchain (stable), Linux/macOS/Windows

# Build from source
cargo build -p filter-repo-rs --release

# Binary at: target/release/filter-repo-rs
Cross-platform builds
# Using build script (recommended)
./scripts/build-cross.sh                    # All platforms
./scripts/build-cross.sh x86_64-apple-darwin # Specific target

# Or manually with cross
cargo install cross --git https://github.com/cross-rs/cross
cross build --target x86_64-unknown-linux-gnu --release -p filter-repo-rs
Platform Target
Linux x64 x86_64-unknown-linux-gnu
Linux ARM64 aarch64-unknown-linux-gnu
macOS Intel x86_64-apple-darwin
macOS Apple Silicon aarch64-apple-darwin
Windows x64 x86_64-pc-windows-msvc

All Use Cases

1. Remove secrets from file contents
# secrets.txt - supports literal and regex
SECRET_TOKEN==>REDACTED
regex:(API|TOKEN|SECRET)[A-Za-z0-9_-]+==>REDACTED

filter-repo-rs --replace-text secrets.txt --sensitive --write-report
2. Clean sensitive commit messages
# messages.txt
password==>[removed]

filter-repo-rs --replace-message messages.txt --write-report
3. Remove large files / slim repo
# By size threshold
filter-repo-rs --max-blob-size 5M --write-report

# By specific blob IDs
filter-repo-rs --strip-blobs-with-ids big-oids.txt --write-report
4. Rename tags/branches in bulk
filter-repo-rs --tag-rename v1.:legacy/v1.
filter-repo-rs --branch-rename feature/:exp/
5. Restructure directory layout
# Extract subdirectory as new root
filter-repo-rs --subdirectory-filter frontend

# Move root to subdirectory
filter-repo-rs --to-subdirectory-filter app/

# Rename path prefixes
filter-repo-rs --path-rename old/:new/
6. Remove specific files from history
# Single file
filter-repo-rs --path docs/STATUS.md --invert-paths

# By glob pattern
filter-repo-rs --path-glob "*.log" --invert-paths

# By regex
filter-repo-rs --path-regex "^temp/.*\.tmp$" --invert-paths
7. CI health checks
filter-repo-rs --analyze --analyze-json

Configure thresholds in .filter-repo-rs.toml:

[analyze.thresholds]
warn_blob_bytes = 10_000_000
warn_commit_msg_bytes = 4096

Backup & Recovery

# Backup creates: .git/filter-repo/backup-YYYYMMDD-HHMMSS.bundle
filter-repo-rs --backup

# Restore
git clone /path/to/backup.bundle restored-repo

Artifacts

After running, check .git/filter-repo/:

  • commit-map β€” old β†’ new commit mapping
  • ref-map β€” old β†’ new reference mapping
  • report.txt β€” change summary (with --write-report)

Limitations

  • Merge simplification still being optimized for complex topologies
  • No incremental processing (--state-branch) yet
  • Windows path policy fixed to "sanitize" mode

Acknowledgments

Inspired by git-filter-repo by Elijah Newren β€” the official Git-recommended history rewriting tool.

  • Choose git-filter-repo for maximum feature completeness
  • Choose filter-repo-rs for performance and memory safety

License

MIT

Links


Built with ❀️ and πŸ¦€ by Cactusinhand

About

πŸ¦€ A high-performance Rust implementation of git-filter-repo for efficiently rewriting Git repository history. Remove sensitive data, shrink repos, and restructure projects with streaming pipeline architecture.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages