> 技术文档 > Git clone代码时报错error: RPC failed; curl 56 Recv failure: Connection was reset_error: rpc failed; curl 56 recv failure: connectio

Git clone代码时报错error: RPC failed; curl 56 Recv failure: Connection was reset_error: rpc failed; curl 56 recv failure: connectio


错误信息:

错误信息解析:

由于git默认缓存大小不足,clone 过程中文件太多或太大、网络断开导致下载失败

解决方案

方法一:增加 Git 缓冲区大小

设置缓冲区大小为(500MB),让 Git 在拉取大文件时更稳定一些

git config --global http.postBuffer 524288000

然后再执行 clone:

git clone https://github.com/apache/echarts-website.git

方法二:使用浅克隆(只克隆最新的提交)

这可以大幅减少下载数据量:

git clone --depth=1 https://github.com/apache/echarts-website.git

或者加上目录名:

git clone --depth=1 https://github.com/apache/echarts-website.git echarts-website

方法三:下载 ZIP 包而不是使用 git

方法四:设置 Git 代理(如你在墙内)

如果你公司网络限制访问 GitHub,可以考虑配置 Git 代理(如 HTTP 代理或 socks5)

例如:

git config --global http.proxy http://127.0.0.1:1080git config --global https.proxy http://127.0.0.1:1080

前提是你有代理服务(如 clash、v2ray、VPN)