preface

Recently, one of my team members told me that he couldn’t git commit code. I asked the reason and he said he would report the code as soon as it was submitted

error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413
fatal: the remote end hung up unexpectedly
fatal: the remote end hung up unexpectedly
Everything up-to-date

Then he told me that he had tried several methods, but none of them worked. The following list of his Baidu out of the scheme

Change the size of the local Git PostBuffer

git config --global http.postbuffer 524288000

Plan 2: Modify the project. Git /config file and add the following contents

[http]  
    postBuffer = 524288000

Scheme 3: Increase the Maximum Attachment Size (MB) and Maximum Push Size (MB) with the Account and Limit of the management Account in GitLab

Can refer to this link https://blog.csdn.net/techfield/article/details/70198077 as junior partner not administrator, behind I tried it, it doesn’t work

The problem’s analyse

1. First look at the problems thrown by git push

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

The only information available to us is probably the status code 413, so we can start with that

This status code means

413 Request Entity Too Large


The server refuses to process the current request because the size of the entity submitted by the request is larger than the server is willing or able to process. In this case, the server can close the connection to prevent the client from sending the request further.

Note: check the HTTP status code information, can be refer to by https://www.php.cn/web/web-http.html

From the meaning of the status code, we can conclude that the uploaded code may be too large. So I asked my friend to look at the amount of code he uploaded, and, boy, it’s 4,50 megabytes

2. Solutions

Plan 1: Upload the code in batches, not all at once

My friend solved the problem according to this plan, but he said it was troublesome, because it was impossible to upload the code in batches every time, because the efficiency of submitting the code was very low

Plan 2: Increase the size of HTTP uploads

The solution is to set the postBuffer in the first place, but the problem is that it doesn’t work. Later, I wondered if it was because of the configuration of the domain name, so I used the Intranet IP way to push the code directly, and the result was actually OK.

Then I went to Ping Gitlab domain name, and found that the IP was not Gitlab’s internal network IP, of course, it could be the external network IP, so I pinged the IP through Baidu, shows that the IP is a local area network.

Then it’s natural to wonder if the project’s GitLab has an agent configured, and then ask the former colleagues who took the GitLab. Sure enough, he used Nginx as the agent to build this GitLab before, so he derived the third scheme

Scenario 3: Modify the NGINX configuration

Add client_max_body_size to the HTTP Server node as follows

http: { server: { client_max_body_size: 200m; }}

Scenario 4: Submit code using SSH

Configure SSH, you can refer to the following link https://blog.csdn.net/qq_42832446/article/details/105533733