如何解决Git推送时出现的‘error: RPC failed; HTTP 408 curl 56 Recv failure: Connection was reset’错误?
Git推送报错:RPC failed; HTTP 408 curl 56 解决方法
报错场景与信息
执行推送命令:
git push -u -f origin --all
触发以下错误输出:
Enumerating objects: 44, done. Counting objects: 100% (44/44), done. Delta compression using up to 8 threads Compressing objects: 100% (43/43), done. Writing objects: 100% (44/44), 213.97 KiB | 3.15 MiB/s, done. Total 44 (delta 1), reused 0 (delta 0), pack-reused 0 error: RPC failed; HTTP 408 curl 56 Recv failure: Connection was reset send-pack: unexpected disconnect while reading sideband packet fatal: the remote end hung up unexpectedly Everything up-to-date
核心错误为:error: RPC failed; HTTP 408 curl 56 Recv failure: Connection was reset,伴随远端连接意外中断提示。
具体解决步骤
增大Git HTTP缓存容量
推送数据包过大易触发超时,执行命令调整缓存:git config --global http.postBuffer 524288000数值单位为字节(上述为500MB),可按需调整。
延长Git网络超时时间
避免因网络延迟导致连接断开,执行以下命令:git config --global http.timeout 300 git config --global http.lowSpeedLimit 0 git config --global http.lowSpeedTime 999999其中
http.timeout设置为300秒,可根据网络情况修改。切换为SSH协议推送
HTTP协议易受网络环境影响,换成SSH协议更稳定。先查看当前远程地址:git remote -v若为HTTP格式(如
https://xxx.git),替换为SSH格式(如git@xxx.git):git remote set-url origin git@xxx.git替换后重新执行推送命令。
排查网络环境
检查当前网络稳定性,尝试切换网络(如WiFi换有线),暂时关闭防火墙、代理工具后重试,避免拦截Git请求。分批推送(针对大仓库)
若仓库含大量历史提交或大文件,减少单次传输数据量:git push origin HEAD:main --force-with-lease先推送最近的提交,再逐步推送历史内容。
内容的提问来源于stack exchange,提问作者Euclides
相关产品推荐
相关产品推荐

