git–push large commits over http fail

Problem : When you try to commit a large size file or trying to commit huge amount of data in single commit you may face this issue. This issue can also be encountered when you are trying to move your source control from other tools like VFS, SVN to git as you will have to move your existing source files in huge commits. Normally you are greeted with below error codes :

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

$ git push origin master
Username for '<HOST>: <USER_EMAIL>
Password for 'http://<USER_EMAIL>@<HOST>':
Counting objects: 3322, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3010/3010), done.
Writing objects: 100% (3322/3322), 29.87 MiB | 8.07 MiB/s, done.
Total 3322 (delta 2379), reused 371 (delta 249)
error: RPC failed; result=22, HTTP code = 413
fatal: The remote end hung up unexpectedly
fatal: recursion detected in die handler
Everything up-to-date

Solutions : Try below solutions as the problem can be caused by several factors :

1)  Change protocol from http(s) to git/ssh

Try to move your repo’s remote connection url from http(s) to git/ssh. You can add remote for your repository using add remote command.$ git remote add origin [email protected]:username/project.git

2) Increase git http post buffer size

The next place to look is git http buffer size settings. To increase git http post buffer size 
you can use below command in your git command prompt
git config http.postBuffer 524288000

3) Increase server (nginx) buffer size

If above does not work than you should be now looking at web server buffer size. git over http will use some kind of web server to process http requests. For example in GitLab it will be nginx by default. To increase buffer size in nginx you need to change the config parameter client_max_body_sizeAdd it to /etc/nginx/sites-available/gitlab on ( in Ubuntu ). In CentOS it be should in /etc/nginx/nginx.conf.

http {
    # ...
    client_max_body_size 16M;
    ...#  }

Change client_max_body_size to whatever you want.