Git push 408 超时、远程断开解决办法

报错说明:推送文件体积较大,上传网速慢,GitHub 服务端等待超时(408 Request Timeout),传输中途连接被切断。

一、先加大 Git 上传缓冲区(最常用,优先执行)

默认缓冲区太小,大文件推送极易断开,调大缓存:

bash 复制代码
# 设置缓冲区500MB,按需改1000m=1G
git config --global http.postBuffer 524288000

二、延长 curl 网络超时时间

默认超时太短,拉长等待时长:

bash 复制代码
# 全局http超时300秒
git config --global http.timeout 300
git config --global https.timeout 300

三、分批次推送,不要一次性 push 全部提交

提交太多、文件太大一次性上传极易断开,拆分推送:

bash 复制代码
# 只推送最近20个提交,数字自行调整
git push origin HEAD~20:main
# 分批多次执行,直到全部推送完成

四、开启低速传输容忍,避免低速直接断连

bash 复制代码
# 低速阈值 1KB/s,持续60秒才断开
git config --global http.lowSpeedLimit 1024
git config --global http.lowSpeedTime 60

完整一键配置命令

bash 复制代码
git config --global http.postBuffer 524288000
git config --global http.timeout 300
git config --global https.timeout 300
git config --global http.lowSpeedLimit 1024
git config --global http.lowSpeedTime 60

执行完后重新执行推送:

bash 复制代码
git push
相关推荐
7177775 小时前
Git自建用什么工具比较好:Gitea、Forgejo、GitLab CE与Gitee的选型对比
git·gitlab·gitea
lsc_blog1 天前
年底还在招的岗位,先确认缺口和到岗要求
git·缓存·ci/cd·职场和发展·github
全栈陈序员1 天前
【Git】从入门到精通(十一)—— git reset 三种模式详解
git·elasticsearch
全栈陈序员1 天前
【Git】从入门到精通(十)—— 撤销与恢复:git checkout与git restore
运维·网络·数据库·git
全栈陈序员2 天前
【Git】从入门到精通(五)—— git add:将文件加入暂存区
大数据·git·elasticsearch
全栈陈序员2 天前
【Git】从入门到精通(七)—— git status:查看仓库状态
大数据·git·elasticsearch
莫晓燚2 天前
Ansible 13 个常用模块---企业实战
git·github
无言听风雨丶2 天前
Kubernetes GitOps 持续交付实战:用 Argo CD 让 Git 成为集群事实源
git·elasticsearch·kubernetes
全栈陈序员2 天前
【Git】从入门到精通(六)—— git commit:提交到版本库
大数据·git·elasticsearch
全栈陈序员3 天前
【Git】从入门到精通(一)—— Git简介:什么是版本控制系统
大数据·git·elasticsearch