5

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.

Shinebayar G
  • 4,624
  • 4
  • 18
  • 29

1 Answers1

3

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    Thanks for answer! What if I want to apply `--strip-blobs-bigger-than 10M` to all branch. Would it keep it latest commits of all branch? (Hoping I won't ruin other branch's latest fixes.) – Shinebayar G Jan 03 '20 at 08:25
  • 1
    Just remove the refs part: do it on a local clone copy, that way you can evaluate the result and see if it is satisfactory. – VonC Jan 03 '20 at 08:54