已调整HTTP配置仍遇git push报错curl 18、send-pack断开问题求助
Git 推送失败问题排查与解决
问题基础信息
- 操作场景:向刚创建的远端仓库执行
git push推送本地文件,操作始终失败 - 已尝试无效的修复操作:
- 切换
http.version配置,分别测试HTTP/2与HTTP/1.1协议,两种场景均推送失败 - 调整
http.postBuffer、http.maxRequestBuffer配置值,问题无改善
- 切换
- 环境确认:本地工作目录内最大单文件仅24.6MB,未达到Git LFS使用阈值;系统仅运行Windows Defender,无其他第三方杀毒、防火墙软件
现有配置节选(来自git config --list输出)
diff.astextplain.textconv=astextplain filter.lfs.clean=git-lfs clean -- %f filter.lfs.smudge=git-lfs smudge -- %f filter.lfs.process=git-lfs filter-process filter.lfs.required=true http.sslbackend=openssl http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt core.autocrlf=true core.fscache=true core.symlinks=false pull.rebase=false credential.helper=manager-core credential.https://dev.azure.com.usehttppath=true init.defaultbranch=master core.editor="C:\Users\username\AppData\Local\Programs\Microsoft VS Code\Code.exe" --wait core.longpaths=true core.compression=0 gui.recentrepo=C:/Users/username/path/to/myRepo http.postbuffer=30000000 http.version=HTTP/1.1 http.maxrequestbuffer=300000000 credential.helper=wincred core.bare=false core.repositoryformatversion=0 core.filemode=false core.symlinks=false core.ignorecase=true core.logallrefupdates=true remote.origin.url=https://github.com/username/myRepo.git remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* remote.origin.pushurl=https://github.com/username/myRepo.git branch.main.remote=origin branch.main.merge=refs/heads/main
git push执行报错日志
Enumerating objects: 177, done. Counting objects: 100% (177/177), done. Delta compression using up to 8 threads Compressing objects: 100% (168/168), done. error: RPC failed; curl 18 transfer closed with outstanding read data remaining send-pack: unexpected disconnect while reading sideband packet Writing objects: 100% (177/177), 444.10 MiB | 612.00 KiB/s, done. Total 177 (delta 5), reused 177 (delta 5), pack-reused 0 fatal: the remote end hung up unexpectedly Everything up-to-date
针对性修复步骤
- 调整压缩等级:当前配置中
core.compression=0,也就是完全关闭Git对象压缩,直接导致本地生成的推送包体积膨胀(从日志看总推送包达444.10MiB),大体积包在弱网环境下极易触发传输中断。执行命令设置低等级压缩:git config --global core.compression 1
该配置在几乎不损失传输速度的前提下,可将推送包体积压缩60%以上,从源头降低包大小。 - 清理重复凭据配置:配置中同时存在两个生效的凭据助手(
manager-core和wincred),重复的身份校验逻辑可能导致连接被远端异常断开。执行命令移除冗余配置,保留单一生效的凭据助手:git config --global --unset credential.helpergit config --global credential.helper manager-core - 匹配实际包大小调整缓冲区:当前设置的
http.postBuffer=30000000仅对应30MB缓冲区,远小于实际444MB的推送包体积,之前的调整未达到适配阈值。执行命令将缓冲区调整为500MB匹配实际传输大小:git config --global http.postBuffer 524288000 - 分批次推送提交:如果上述调整后仍失败,可将整批提交拆分为小批次逐次推送,降低单次连接的传输压力。先通过
git log获取各提交的哈希值,从最早的提交开始,逐次执行git push origin 提交哈希:main完成全部内容推送。 - 临时验证防护软件影响:临时关闭Windows Defender实时扫描功能,再次执行推送,排除防护软件扫描传输中Git包导致连接中断的可能。
内容的提问来源于stack exchange,提问作者michen00
相关产品推荐
相关产品推荐

