0

The repo is containing folder with binary files and that causes increasing the pack size in .git folder, now .git is ~800MB (80% of total size) and repo size is 1GB.

I've tried to delete the folder and commit it and do all these git gc, git fsck, git prune,... but no change in size of the pack.

there are a lot of suggestion with a simple search on google but none of them working for me!

so how can I reduce my repo size, should I delete files from history one by one which is definitely not a solution for me as there are lots of them!!

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
MK83
  • 1,652
  • 1
  • 11
  • 11
  • 1
    As long as there are commits containing the big files, you cannot reduce your repo size. Look at git filter-repo (https://github.com/newren/git-filter-repo/) for automatic cleaning of history. Be careful, it means rewriting history, so not advised for already published and shared repository. – zigarn Aug 20 '21 at 12:33
  • Thank you, actually this is was the key that I missed! "_commits containing the big files_", so I like this library more as I think it is more safer than the proposed answer because I can specify the folder and not just base on blob size. – MK83 Aug 20 '21 at 13:56
  • https://stackoverflow.com/search?q=%5Bgit%5D+remove+large+file+history – phd Aug 20 '21 at 13:56

1 Answers1

1

The solutions is to remove large binary files, but not one at time by hand.

Instead you should use the BFG tool powerful tool.

Here is an example (as described by the above link):

git clone --mirror git://example.com/some-big-repo.git

java -jar bfg.jar --strip-blobs-bigger-than 100M some-big-repo.git

cd some-big-repo.git

git reflog expire --expire=now --all && git gc --prune=now --aggressive

git push
Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
  • Thanks! This one is also working, but just relay on blob size is kind of the restriction! I've tried it and I can save more than the command `git-filter-repo` but not possible to use it on folder just the file extensions. – MK83 Aug 20 '21 at 14:01
  • Please, accept the solution it solved your problem. ;) – Antonio Petricca Aug 20 '21 at 14:55