Use the BFG Repo-Cleaner, a simpler, faster alternative to git-filter-branch
, specifically designed for removing unwanted files from Git history.
Carefully follow the usage instructions. The core part is just this:
java -jar bfg.jar --strip-blobs-bigger-than 100M my-repo.git
Any files over 100 MB in size (that aren’t in your latest commit) will be removed from your Git repository’s history. You can then use git gc
to clean away the dead data:
git reflog expire --expire=now --all && git gc --prune=now --aggressive
After pruning, we can force push to the remote repo*
git push --force
Note: cannot force push a protect branch on GitHub
The BFG is typically at least 10-50 times faster than running git-filter-branch
, and generally easier to use.
Full disclosure: I’m the author of the BFG Repo-Cleaner.