Summary of my problem: One of my private repositories on Bitbucket suddenly more than doubled in size after I pushed an addition of a few hundred bytes to two existing files. The repo is now over 2GB, which has caused Bitbucket to put it into read-only mode. Because it is in read-only mode, I cannot push changes that would reduce the repo size. (Catch 22.)
Details: My company recently began hosting git repositories on Bitbucket. One of the repositories I am in charge of had a size of about 973MB, which was uncomfortably close to the 1GB soft limit. To reduce the repo size, I followed the instructions in the Bitbucket documentation article Split a repository in two and moved about 450MB worth of documentation and online help files into their own private repo. I then followed the instructions in the Bitbucket documentation articles Reduce repository size and Maintaining a git repository, specifically:
git count-objects -vH
showed me a size-pack of about 973MB.
I ran git filter-branch --index-filter 'git rm --cached --ignore-unmatch doc' HEAD
to remove the doc directory (which is the content I'd moved to the new repo).
I ran the following commands to expire reference and prune:
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d git reflog expire --expire=now --all git gc --prune=now
git count-objects -vH
then showed me a size-pack of 881.1 MiB and du -sh .git/objects
returned 882M. I was disappointed that moving over 450MB reduce the repo size by less than 90MB, but pushed the changes to Bitbucket nevertheless:
git push --all --force git push --tags --force
The settings page for the Bitbucket copy of the repo continued to show a size of 973MB. I logged out, refreshed the browser, logged back in, but that didn't help -- the repo size remained at 973MB.
This morning (three days after the changes described above) I made a couple of minor additions to two existing files which increased the files' sizes by a total of less than 1KB, added and commited them to my local repo, then pushed the change to Bitbucket. A few minutes later I took a look at the Bitbucket page for the repo and saw a red warning banner informing me "This repo is over the 2 GB limit and is in read-only mode." The settings page now says the repo has a size of 2.3 GB.
The push of a few hundred bytes added to two files was definitely the only activity to occur on the remote repo in the last three days, according to Bitbucket. That push may not have been the cause of the repo more than doubling in size, but the two events were closely correlated in time.
git reflog show
returns nothing.
Cloning a new copy into an alternate directory, then running git count-objects give me a size-pack of 881.29 MiB.
The local repository is on a CentOS 6.5 system. git version is 1.8.5.3.
Questions
remove the file from your project's current file-tree. remove the file from repository history — rewriting Git history, deleting the file from all commits containing it. remove all reflog history that refers to the old commit history. repack the repository, garbage-collecting the now-unused data using git gc.
10 GB limit This limit is a "hard limit," which matches our download limit and helps us maintain a high level of service for all our users. Git repositories are inefficient at these sizes, so the performance you experience locally will be degraded while consuming more resources on our systems.
In Bitbucket Cloud, a repository admin can see the size under "Repository Details" under Settings. In Bitbucket Server too, you can view it under Settings > Repository Details after clicking on "Retrieve Size Details".
Shrink a Git Repository by removing some files log history from the . git Folder based on their last updated time. git-prune-packed - Remove extra objects that are already in pack files.
I've found that the easiest way to reduce the Bitbucket repo size if you are over the 2GB limit is to
This should trigger Bitbucket to run git gc
on the repo.
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