如何减少Bitbucket上的git repo大小? [英] How to reduce git repo size on Bitbucket?

查看:1265
本文介绍了如何减少Bitbucket上的git repo大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题摘要:在将两百个字节添加到两个现有文件后,Bitbucket上的一个私人存储库突然增加了一倍以上。回购现在超过2GB,导致Bitbucket将其置于只读模式。由于它处于只读模式,因此我无法推送会降低回购大小的更改。 (Catch 22。)



详细信息:我的公司最近开始在Bitbucket上托管git存储库。我负责的一个版本库的大小约为973MB,与1GB软限制不相称。为了减少回购大小,我遵循Bitbucket文档将存储库分成两部分,并将大约450MB的文档和联机帮助文件移动到其自己的专用回​​购站中。然后,我按照Bitbucket文档中的说明减少存储库大小和< a href =https://confluence.atlassian.com/display/BITBUCKET/Maintaining+a+Git+Repository =noreferrer>维护一个git仓库,特别是:



git count-objects -vH 显示我的大小约为973MB。

p>我运行了 git filter-branch --index-filter'git rm --cached --ignore-unmatch doc'HEAD 删除doc目录(这是内容我已经转移到新的回购)。



我运行以下命令来过期引用和修剪:

  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 然后向我展示了881.1 MiB和 du -sh .git / objects 返回882M。我感到失望的是,超过450MB的回购大小减少了不到90MB,但将更改推到了Bitbucket:

  git push --all --force 
git push --tags --force

设置页面为回购的Bitbucket副本继续显示973MB的大小。我退出了,刷新了浏览器,但是这并没有帮助 - 回购大小保持在973MB。



今天上午(更改后的三天如上所述)我对两个现有文件做了一些小增加,这些文件增加了文件大小不到1KB,并将它们添加到本地回购,然后将更改推送到Bitbucket。几分钟后,我查看了回购的Bitbucket页面,并看到一条红色警告标语,通知我此回购超过2 GB限制并处于只读模式。设置页面现在说repo的大小为2.3 GB。

在两个文件中添加了几百个字节的数据绝对是远程发生的唯一活动根据Bitbucket的说法,在过去的三天内回购。这种推动可能不是造成回购的原因超过两倍,但这两个事件在时间上密切相关。

git reflog显示不会返回任何内容。



将新副本克隆到备用目录中,然后运行git count-objects给我一个881.29 MiB 。



本地存储库位于CentOS 6.5系统上。 git版本是1.8.5.3。

问题


  1. 为什么将450MB文件移出回购站只能将本地回购站的大小减少90MB?
  2. 为什么这种适度减少不会被推到Bitbucket上的远程回购站?

  3. 地球上的远程回购大小如何从973MB跳到2.3GB?

  4. 如何修复它?即使使用--force标志,我也无法推送到远程回购。任何推送都会收到错误消息conq:存储库处于只读模式(超过2 GB大小限制)。
    致命:无法从远程存储库读取数据。


解决方案

在授予Bitbucket技术支持后,我现在可以回答一些我自己的问题:


  1. 为什么将450MB文件移出回购站只能将本地回购的大小
    减少90MB?历史上的某些东西被遗漏了。我
    不是什么,但filter-branch命令错过了一些东西。
    通过运行
    ,我能够成功地将回购大小减少450MB,这个实用程序 BFG Repo-Cleaner

  2. 为什么即使这种适度减少也没有被推到Bitbucket的远程仓库
    上?它的确如此,但Bitbucket支持必须在
    上运行git gc。可以联系Bitbucket请求,并要求他们在回购协议中运行
    git gc。
  3. 远程回购大小如何从973MB跳转到2.3GB?
    未知。 Bitbucket的技术支持也没有答案。
  4. 我如何解决这个问题?联系Bitbucket支持。他们可以将一个
    存储库放回到读写模式,以便您可以推送一个较小的
    存储库,并且可以在它们的最后运行git gc。


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

  1. Why did moving 450MB of files out of the repo only reduce the size of my local repo by 90MB?
  2. Why did even that modest reduction not get pushed to the remote repo on Bitbucket?
  3. How on Earth did the remote repo size jump from 973MB to 2.3GB?
  4. How do I fix it? I cannot push to the remote repo even with the --force flag. Any push gets me the error message "conq: repository is in read only mode (over 2 GB size limit). fatal: Could not read from remote repository."

解决方案

After conferring with Bitbucket technical support, I can now answer some of my own questions:

  1. Why did moving 450MB of files out of the repo only reduce the size of my local repo by 90MB? Something in the history got missed. I don't what exactly, but the filter-branch command missed something. I was able to successfully reduce the repo size by 450MB by running the utility BFG Repo-Cleaner.
  2. Why did even that modest reduction not get pushed to the remote repo on Bitbucket? It did, but Bitbucket support must then run git gc on their side. One can contact Bitbucket request and ask them to run git gc on a repo.
  3. How on Earth did the remote repo size jump from 973MB to 2.3GB? Unknown. Bitbucket technical support didn't have the answer to this one either.
  4. How do I fix it? Contact Bitbucket support. They can put a repository back into read-write mode so that you can push a smaller repository and they can run git gc on their end.

这篇关于如何减少Bitbucket上的git repo大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆