gitgit-rewrite-historygit-gc

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?


Solution

  • 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.