解决 GitHub 上传大文件失败的问题

63042466_p0.jpg

转载:https://www.bboysoul.com/

简介

首先亮出报错关键字

1
2
3
error: RPC failed; result=22, HTTP code = 413
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

反正问题的关键就是 GitHub 限制了上传的文件大小

思路

解决这个问题要从两个地方入手
一个是客户端也就是我们自己使用的 Git 客户端,另外一个是服务端,也就是 GitHub 服务器

首先解决自身的问题

也就是增大本地客户端可以上传代码的大小限制,输入下面的命令即可解决

1
2
git config --global http.postBuffer 524288000
git config --global https.postBuffer 524288000

之后就是服务端的问题

服务端的限制有两个地方一个是 gitlab 本身,另外一个是 gitlab 使用的 nginx
gitlab 本身也是很好解决的,使用管理员用户登录 gitlab 在设置 Account and limit 中加大 Maximum attachment size (MB) 和 Maximum push size (MB) 即可解决

nginx 的话修改 gitlab.rb 这个文件中

1
2
3
4
nginx['enable'] = true
nginx['client_max_body_size'] = '1024m'
nginx['redirect_http_to_https'] = false
nginx['redirect_http_to_https_port'] = 80

之后重启

1
2
gitlab gitlab-ctl reconfigure
gitlab gitlab-ctl restart

就好了

还有要注意的是,我在 gitlab 前面还加了一个 nginx 用来做反向代理,所以这个 nginx 的 client_max_body_size 也要加大

Logo

免费领 150 小时云算力,进群参与显卡、AI PC 幸运抽奖

更多推荐