I have a Bitbucket repository whereby there's a repo size limit of 2.0 GB. I had created a .gitignore
but forgot to add the downloads/documents to it and thus the repo became 8.3 GB.
After I saw the notice in Bitbucket, I quickly ran
$ git rm -r /path/to/docs
After doing the usual git add
etc. commands, I got this push error:
repository is in read only mode (over 2 GB size limit).
Learn how to reduce your repository size: https://confluence.atlassian.com/x/xgMvEw.
fatal: Could not read from remote repository.Please make sure you have the correct access rights and the repository exists.
Which led me to use these commands:
$ du -sh project-root/
This returns:
6.0G project-root
This was a bit worrying as I just removed all of the documents, no way could it be that size. So I ran:
$ du --max-depth=10 -h project-root | sort -n -r
The directory that stands out most is:
5.7G project-root/.git/objects/pack
5.7G project-root/.git/objects
5.7G project-root/.git
In turn, I ran git gc
- but this had no effect (or at least in sizing terms).
So how do I reduce the size of my .git/objects
directory? I imagine the size was contributed to by the large documents folders, but now they're gone. So how do I "clean" up my git objects?