preface

Recently, a team member told me that he couldn’t commit his code to Git. I asked why, 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
Copy the code

Then he told me he tried several methods, but nothing worked. Here are his solutions

Solution 1: Change the size of the local Git postbuffer

git config --global http.postbuffer 524288000
Copy the code

Solution 2: Modify the project. Git /config file and add the following content

[http]  
    postBuffer = 524288000
Copy the code

Scheme 3: Increase the Maximum attachment size (MB) and Maximum push size (MB) with the Account and limit of the management Account in gitlab

You can refer to the link blog.csdn.net/techfield/a… Since the partner is not the administrator, I tried this scheme later, but it didn’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
Copy the code

The information that’s useful to us is probably 413, so we can start with that state code

The meaning of this status code is

413 Request Entity Too Large

The server refused to process the current request because the size of entity data submitted by the request was larger than the server was willing or able to process. In this case, the server can close the connection to prevent the client from continuing to send the request.

Note: You can view the HTTP status code information at www.php.cn/web/web-htt… To refer to

From the meaning of the status code, we can conclude that the uploaded code may be too large. So I asked my friend to take a look at how much code he had uploaded, and, boy, it was 4,50 megabytes

2. Solutions

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

My friend solved the problem by following this plan, but he said that it was very troublesome, and I could not upload the code in batches every time, so the efficiency of submitting the code was very low

Solution 2: Increase the HTTP upload size

The solution was to set the Postbuffer in the first place, but the problem was that it didn’t work. Later, I wondered if it was because of the configuration of the domain name, so I used the internal IP directly to push the code, but it was actually ok.

Then I went to ping the domain name of Gitlab, and found that the IP was not the Intranet IP of Gitlab, of course, the ping might be an external IP, so I pinged the IP through Baidu, and showed that the IP was a local LAN.

Then it was natural to think whether the gitLab of the project was configured with agents, and then to ask the former colleagues who took this Gitlab. Sure enough, he used NGINx as an agent to build this gITLab before, and then derived a third scheme

Solution 3: Modify the nginx configuration

Add client_max_body_size to the HTTP server node like the following

http: { server: { client_max_body_size: 200m; }}Copy the code

Scheme 4: Use SSH to commit code

To configure SSH, see blog.csdn.net/qq_42832446…