报错代码
error: RPC failed; curl 18 Transferred a partial file
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
解决方案
增大 HTTP buffer 缓冲区
git config --global http.postBuffer 524288000
http.postBuffer
的默认值只有 1MB。- 这里设置成
524288000
(≈500MB),就是允许 Git 在传输时用更大的缓冲,避免下载大文件/大仓库时中途断开。
强制使用 HTTP/1.1
git config --global http.version HTTP/1.1
- Git 默认可能用 HTTP/2,但有时候 GitHub/GitLab 的 HTTP/2 连接会有兼容性问题。
- 改成
HTTP/1.1
更稳定。
禁用低速限制
git config --global http.lowSpeedLimit 0 git config --global http.lowSpeedTime 999999
http.lowSpeedLimit
:如果下载速度低于多少 KB/s 就认为失败。默认是1 KB/s
。http.lowSpeedTime
:持续多少秒低速就断开。默认是30s
。- 这两条命令相当于:不管多慢,只要不断就继续下载。