I have a project with ~12MB worth of code and assets in it. I've been tracking it using Git, and just noticed that my .git
folder is now just over 1.83GB. It consists of a few small files, and then just one pack file that makes up about 1.82GB of the folder.
I've run git gc --aggressive
and git gc --prune
. It's the same size. I've tried:
git reflog expire --expire=now --all
git repack -ad # Remove dangling objects from packfiles
git prune # Remove dangling loose objects
But it's still the same size. I've even cloned it (once locally with a forced repack, and once again from Git), but it's still 1.83GB on each. Is that normal? Is there any way to reduce the size of it, or do I just start a new repo, copy the code over, and accept that my past commits will be gone?
We recommend reducing the repository size by removing objects that are no longer referenced using git prune , in addition to optimizing via git gc . You may also want to review the repository for large files, then exclude them as needed.
File size limits GitHub limits the size of files allowed in repositories. If you attempt to add or update a file that is larger than 50 MB, you will receive a warning from Git. The changes will still successfully push to your repository, but you can consider removing the commit to minimize performance impact.
Ok, the comments were a great start to understand what the root cause of the problem probably was. I don't really understand the git filter-branch
command though, so I was a little wary of just using that.
I came across this tool: https://rtyley.github.io/bfg-repo-cleaner/
It worked wonders. My repo is now under 10MB.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With