问题
在git clone大仓库(>10G)时,出现一下错误:
错误1
git clone http://bitbucket.company.com:7990/scm/proj/repo.git
fatal: early EOF
fatal: The remote end hung up unexpectedly
fatal: index-pack failed
error: RPC failed; result=56, HTTP code = 200
Completed with errors, see above.
错误2
git clone http://bitbucket.company.com:7990/scm/proj/repo.git. Cloning into 'repo'....git
remote: Counting objects: , done.
remote: Compressing objects: 100% (####/###), done.
fatal: The remote end hung up unexpectedly.00 GiB | MiB/s
fatal: early EOF
fatal: index-pack failed
查看诊断
添加一下环境变量,重新clone查看诊断信息.
export GIT_TRACE_PACKET=1
export GIT_TRACE=1
export GIT_CURL_VERBOSE=1
问题原因
Cause #1
git debug output has error: RPC failed; result=56, HTTP code = 200
Error code 56 indicates a curl receive error of CURLE_RECV_ERROR which means there was some issue that prevented the data from being received during the clone process. Typically this is caused by a network setting, firewall, VPN client, or anti-virus that is terminating the connection before all data has been transferred.
Cause #2
There is no error code and git debug log shows that Nginx is configured as reverse proxy. Git clone fails after 1 GB.
解决办法
Resolution for Cause #1
Change the anti-virus settings, firewall settings, or VPN client so that they allow connections from Bitbucket Server and do not terminate them prematurely. The specific change that needs to be done will depend on the technology being used and sometimes it will be helpful to check the vendor documentation.
Resolution for Cause #2
Disable the default 1GB limit of proxy_max_temp_file_size for Nginx. Value need to be set as zero to disable it
You can find more details here
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_max_temp_file_size
总结
我是通过BT面板代理的gitlab服务,所以在BT的运行环境Nginx中修改配置,将proxy_max_temp_file_size加大即可:
client_max_body_size 40960m; #修改push最大文件大小
proxy_max_temp_file_size 40960m; #修改clone时最大文件大小