git push出现 “HTTP 400 curl 22 The requested URL returned error: 400...“错误
错误内容是:
错误:RPC 失败。HTTP 400 curl 22 The requested URL returned error: 400 send-pack: unexpected disconnect while reading sideband packet
致命错误:远端意外挂断了
检查发现;文件大小5M,远低于100M;网络正常5-7Mbps;git版本正常。
使用的解决方法是:改用SSH推送
步骤如下:
- 检查本地是否已经有SSH Key
ls ~/.ssh
正常会看到 id_rsa.pub、id_ed25519.pub 之类的文件。(有,跳到第3步)
- 如果没有SSH key,先生成:
ssh-keygen -t ed25519 -C "你的邮箱"
(如果不支持 ed25519,可以用 -t rsa -b 4096)
一路回车,默认存到 ~/.ssh/id_ed25519。
- 查看并复制公钥内容:
cat ~/.ssh/id_rsa.pub # 终端输入
会输出一长串以 ssh-rsa 开头的内容,全部复制。
-
将公钥添加到GitHub
(1)打开github SSH keys页面
(2)点击右上角绿色的【New SSH Key】
(3)Title随便填写,比如 windowskey,MacBookKey等
(4)Key部分粘贴刚才复制的公钥内容
(5)点击【Add SSH key】 -
验证SSH链接
终端输入:
ssh -T git@github.com
出现:
Hi your-username! You've successfully authenticated...
就说明一切正常。
- 将自己的内容再次推送到github
git push
以上全部跑一遍,我这边推送成功。