解决git push遇到413和510RPC错误

说明

如题,在使用git上传我的hexo配置仓库到我自己搭建的gitea上时,遇到了这个报错。

说明:该仓库已在gitea中存在,但是很久没有更新过(数个月),一次push的更新量较大

所以就遇到了这个报错!下面给出两个报错的完整输出

1
2
3
4
5
6
7
8
9
10
PS D:\HEXO\blog> git push nas
Enumerating objects: 30332, done.
Counting objects: 100% (30332/30332), done.
Delta compression using up to 16 threads
Compressing objects: 100% (12271/12271), done.
Writing objects: 100% (30332/30332), 54.44 MiB | 127.27 MiB/s, done.
Total 30332 (delta 10987), reused 29639 (delta 10321), pack-reused 0
error: RPC failed; HTTP 520 curl 22 The requested URL returned error: 520
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly
1
2
3
4
5
6
7
8
9
10
PS D:\HEXO\blog> git push nas
Enumerating objects: 30332, done.
Counting objects: 100% (30332/30332), done.
Delta compression using up to 16 threads
Compressing objects: 100% (12271/12271), done.
Writing objects: 100% (30332/30332), 54.45 MiB | 135.99 MiB/s, done.
Total 30332 (delta 10984), reused 29639 (delta 10321), pack-reused 0
error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly

解决思路

第一步当然是百度了,百度到了这篇知乎文章

知乎文章 https://zhuanlan.zhihu.com/p/359316694

先依照第一个步骤,设置本地的buffer大小,再去尝试push

1
git config --global http.postbuffer 524288000

配置完毕这个命令后,原本是520的报错,变成了413报错

1
error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413

再看文章内的分析

413 Request Entity Too Large
服务器拒绝处理当前请求,因为该请求提交的实体数据大小超过了服务器愿意或者能够处理的范围。此种情况下,服务器可以关闭连接以免客户端继续发送此请求。

考虑到我的云服务器是用nginx来反代gitea的,所以就采用文章中的第三步,修改nginx配置;

在gitea的nginx配置文件中的server体内新增了如下限制

1
client_max_body_size 200m;

重新启动nginx,就搞定了!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
PS D:\HEXO\blog> git push nas
Enumerating objects: 30332, done.
Counting objects: 100% (30332/30332), done.
Delta compression using up to 16 threads
Compressing objects: 100% (12271/12271), done.
Writing objects: 100% (30332/30332), 54.44 MiB | 136.63 MiB/s, done.
Total 30332 (delta 10987), reused 29638 (delta 10321), pack-reused 0
remote: Resolving deltas: 100% (10987/10987), done.
remote:
remote: Create a new pull request for 'hexo':
remote: https://gitea.musnow.top/musnow/HexoBlog/compare/main...hexo
remote:
remote: . Processing 1 references
remote: Processed 1 references in total
To https://gitea.musnow.top/musnow/HexoBlog.git
* [new branch] hexo -> hexo

成功push到gitea的远程仓库!