git push 报错:error: RPC failed; result=22, HTTP code = 413 fatal: The remote end hung up unepectedly

  目录

一、问题描述

二、解决方法

2.1 方法一:将传输方式由 http 改为 ssh (推荐)

2.2 修改提交缓存大小为500M,或者更大

2.3 设置 git 最低速度和最低速度时间

三、总结

四、参考链接


一、问题描述

git 在 push 的时候可能会出现如下错误:

error: RPC failed; result=22, HTTP code = 413
fatal: The remote end hung up unepectedly 

出现这个错误的主要原因是传输的内容比较大。

二、解决方法

本文测试均以本人新建的 github 仓库 My_String 为例进行说明,其中克隆该仓库使用的是 http 方式。

2.1 方法一:将传输方式由 http 改为 ssh (推荐)

如果使用的是 http 传输,将其改为 ssh 传输。

(1)使用 git remote -v 查看你的连接情况,确认当前使用的是 http 方式,如下所示:

[root@bogon My_String]# git remote -v
origin  https://github.com/New-World-2019/My_String.git (fetch)
origin  https://github.com/New-World-2019/My_String.git (push)
[root@bogon My_String]#

2. 在 github My_String 仓库中复制 ssh 的连接,如下图所示:

3. 修改传输方式 http 为 ssh,执行命令 git remote set-url origin "SSH连接",如下所示:

[root@bogon My_String]# git remote set-url origin [email protected]:New-World-2019/My_String.git
[root@bogon My_String]# git remote -v
origin  [email protected]:New-World-2019/My_String.git (fetch)
origin  [email protected]:New-World-2019/My_String.git (push)
[root@bogon My_String]#

改完之后,正常 push 就可以啦。

2.2 修改提交缓存大小为500M,或者更大

执行命令 git config --global http.postBuffer Size 进行设置,如下所示:

[root@bogon My_String]# git config --global http.postBuffer 524288000
[root@bogon My_String]# git config --global http.postBuffer 1048576000

2.3 设置 git 最低速度和最低速度时间

执行命令 git config --global http.lowSpeedLimit Time 进行设置,如下所示:

[root@bogon My_String]# git config --global http.lowSpeedLimit 0
[root@bogon My_String]# git config --global http.lowSpeedTime 999999

三、总结

我推荐使用第一种方式,另外两种方式治标不治本,另外,建议不要将不使用的/不重要的/可执行文件传输到仓库中,这可以通过仓库下.gitignore 进行筛选,如果没有新建一个即可。

四、参考链接

[1] https://blog.csdn.net/weixin_38450840/article/details/80701173

[2] https://blog.csdn.net/WangYouJin321/article/details/106329757

猜你喜欢

转载自blog.csdn.net/u011074149/article/details/108818608
今日推荐