Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Repository Too Large

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?

like image 212
Bryce Avatar asked Mar 25 '13 01:03

Bryce


People also ask

How do I reduce the size of a Git repository?

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.

How large is too large for a Git repo?

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.


1 Answers

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.

like image 76
Bryce Avatar answered Sep 28 '22 04:09

Bryce