You’re referring to BFG Repo-Cleaner — a tool written in Scala that’s used to quickly remove large or sensitive files (blobs) from Git history, similar to git filter-branch, but much faster and easier to use.
🔧 What BFG Does
BFG is ideal for:
Removing large files (e.g.,
.zip,.mp4,.iso)Deleting sensitive data (e.g., passwords, tokens)
Cleaning up bloated Git repositories
🧰 BFG vs git-filter-branch
| Feature | BFG Repo-Cleaner | git-filter-branch |
|---|---|---|
| Language | Scala (JVM required) | Shell + Git |
| Speed | ⚡ Much faster | 🐢 Very slow |
| Ease of use | Simple commands | Complex and verbose |
| Recommended by Git? | ✅ Yes | ⚠️ Deprecated by Git |
✅ How to Use BFG (Quick Start)
1. Install BFG
Download the .jar from:
👉 https://rtyley.github.io/bfg-repo-cleaner/
Or via [Homebrew] (macOS):
brew install bfg
2. Clone Your Repo as a Bare Repo
git clone --mirror https://bitbucket.org/your/repo.git cd repo.git
3. Remove Large Files
To delete all files over 100MB:
java -jar bfg.jar --strip-blobs-bigger-than 100M
To delete specific file types (e.g., .mp4, .zip):
java -jar bfg.jar --delete-files '*.mp4' '*.zip'
4. Clean and Push
git reflog expire --expire=now --all git gc --prune=now --aggressive git push --force
This rewrites history — notify collaborators beforehand!
Want to See Large Files First?
Use this to check which blobs are the largest:
git rev-list --objects --all | \ git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | \ grep '^blob' | sort -k3 -n -r | head -n 20
