我在获取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