I'm trying to use this tool to shrink my .git
folder size which is 3.1GB right now. Code is under 100MB. This repo is very old and has many branches ~250.
If I use this tool on master branch, what will happen to other branches? It mentions:
By default the BFG doesn't modify the contents of your latest commit on your master (or 'HEAD') branch, even though it will clean all the commits before it.
So I assume it would break up things in other branches? Or it doesn't break latest commits on other branches? What I want to achieve is as long as other branches' latest commit is safe, I'm fine.
That is precisely what the new tool git filter-repo
, which replaces BFG and git filter-branch
, avoids: it does rewrite all the way to the latest commit.
See its user manual
git filter-repo --strip-blobs-bigger-than 10M --refs master
It automatically removes old cruft and repacks the repository for the user after filtering (unless overridden); this simplifies things for the user, helps avoid mixing old and new history together.
As show here (applied only on master
), that won't touch the other branches, but yes, the new master
branch might no longer share any common history with other branches.