git clone 时仓库过大

我在获取Odoo源码的时候出现的问题:

$ git clone https://gitee.com/mirrors/odoo.git
Cloning into 'odoo'...
remote: Enumerating objects: 2561901, done.
remote: Counting objects: 100% (2561901/2561901), done.
remote: Compressing objects: 100% (382781/382781), done.
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
  • $ git clone https://gitee.com/mirrors/odoo.git
    Cloning into 'odoo'...
    remote: Enumerating objects: 2561901, done.
    remote: Counting objects: 100% (2561901/2561901), done.
    remote: Compressing objects: 100% (382781/382781), done.
    error: RPC failed; curl 18 transfer closed with outstanding read data remaining
    fatal: The remote end hung up unexpectedly
    fatal: early EOF
    fatal: index-pack failed

Odoo源码已经在1GB以上,在确认网络没有问题的前提下,发现是git的仓库缓存资源不够,而后默认设置2GB缓存,仓库获取正常:

  • 1$ git config --global http.postBuffer 2097152000

我们可以通过以下命令行检查git配置参数:

git config --list
  • 1
...
alias.plo=pull origin
alias.cm=commit -m
alias.ap=add -p
alias.df=diff
alias.cob=checkout -b
alias.bd=branch -D
alias.mnf=merge --no-ff
alias.fco=fetch origin
alias.fc=fetch
http.postbuffer=2097152000

注意


有时候虽然设置的缓存变大了,但某些仓库真的让人头疼,比如Odoo12,现在整个odoo仓库达到2.3GB.设置缓存会变得让人难过, 而且git会检测内存不能超出一定范围,否则会 out of range.

  •  解决办法
    我们的命令:git clone https://gitee.com/mirrors/odoo.git
    实际上会将仓库的所有内容和分支都获取下来,这显然不是我们所要的结果,我们可以指定一个分支最近的一次提交,这样我们获取的就是最近最新的特定分支
git clone -b 指定的分支名称 --depth 1 仓库地址
即举例:
git clone -b 13.0 --depth 1 https://gitee.com/mirrors/odoo.git

我们发现可能只有100-200MB的压缩包被下载下来,自动解压后到达最近最新的特定分支的状况

如果要切换分支,请使用:

$ git fetch --depth 1 origin 12.0:12.0
$ git checkout 12.0
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值