Search code examples
gitgithubgit-rewrite-historybfg-repo-cleanergit-lfs

How to shrink Git repo and better manage large files


I've used the BFG repo cleaner in the past with great success. I've also recently started tinkering with Git LFS, although I'm still learning.

I had previously .gitignored many large files, and when I started tracking then with LFS, the .git/ folder became huge (due to .git/lfs/objects, mostly).

  1. By tracking files with Git LFS, am I going to massively increase my repo size right off the bat? That's been my experience so far, but it seems unnecessary (perhaps).

I see that BFG now supports Git LFS. It says I can use that command to reduce the size of my repo, and track with LFS.

  1. Is there a way to specify the size of the file to clean with BFG then track with LFS, or does it simply perform these actions for all files matched (based on name)?

I've been experimenting to try and find the answers to these questions, but progress has been slow.


Solution

    1. Objects are stored without compression in the .git/lfs/objects folder (unlike git pack files, which use gzip and delta-compression), so size increase is definitely possible
    2. That would be possible, but isn't currently implemented in the BFG. Because git lfs depends on gitattributes, which are filename glob patterns, it would be fiddlyish.