shubhangi singh
shubhangi singh

Reputation: 2930

git push failure while pushing a large respository of code

I am trying to push my code from an old repository to a new repository as my old repository seems to be currupted somehow

getting following error:

Counting objects: 19815, done.
Compressing objects: 100% (5264/5264), done.
Writing objects: 100% (19815/19815), 44.91 MiB | 134.87 MiB/s, done.
Total 19815 (delta 14641), reused 19405 (delta 14283)
error: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400 Bad Request
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Everything up-to-date

I tried git config http.postBuffer 524288000 but it did not help I even tried to do git push --force origin and git push --all but am receiving same error

Upvotes: 261

Views: 174789

Answers (12)

Mahesh Jamdade
Mahesh Jamdade

Reputation: 20369

If nothing works You can try breaking your large commit into smaller commits

  1. run git log and see which commit is too large to push
  2. undo until that large commit by repeatedly running git reset --soft HEAD~1
  3. Make remote in sync with local git pull
  4. Now make several partial commits and push

Upvotes: 0

Finnian Logan-Riley
Finnian Logan-Riley

Reputation: 21

This happened to me as I had 3k new files inside of a single commit. I fixed it by splitting this commit into smaller commits.

Upvotes: 0

rodrigo franco
rodrigo franco

Reputation: 320

I've got the same problem and could solve the problem running this command git config --global http.postBuffer 157286400. I found this command on https://thewayeye.net/posts/fixing-the-rpc-failed-http-400-error-in-git/

The origin of the problem: I was trying to upload a Jupyter notebook that had graphs printed on, so that made the file big enough for hitting the buffer limit.

Upvotes: 5

LEO CHEN
LEO CHEN

Reputation: 2303

I faced this error on my mac and solved with this command git config --global http.postBuffer 157286400.

Upvotes: 211

d42k5742
d42k5742

Reputation: 21

I'm pushing a React website that has some images larger than 2MB. I'm surprised that 2MB-ish is an issue but regardless, I switched to SSH and the problem went away. There's plenty of advice on how to do that in this post: How to migrate from HTTPS to SSH github.

What is annoying is that there's an inconsistency between push over HTTP and push over SSH so, I don't imagine it is a Git constraint but rather a constraint of the GitHub HTTP API or HTTP itself.

Upvotes: 0

Parikshit Gupta
Parikshit Gupta

Reputation: 31

This was because I was pushing a lot of data to Github. Forgot to add node_modules in the .gitignore

Upvotes: 1

Saran Sinha
Saran Sinha

Reputation: 29

I was getting the same error even after updating the buffer size and HTTP version. This simple command worked for me

git push --all

Upvotes: 2

Slinky Sloth
Slinky Sloth

Reputation: 301

I've encountered this issue when attempting to push a new branch to my repository. Failed with exactly this error. This is possibly a network issue caused by using an external VPN connection in my case. I managed to resolve it by lowering the MTU in my debian machine:

ip link set eth0 mtu 800

Upvotes: 0

Mbalire Shawal
Mbalire Shawal

Reputation: 6881

I faced a similar issue on my Arch Linux machine. Apparently my issue was an HTTP buffer issue.

I got it to work by using

git config http.postBuffer 524288000

followed by

git pull && git push

This did the trick for me and I can push to my repositories. However I wonder if there is a better way of implementing this rather than running an extra command.

Upvotes: 676

Christoph Schranz
Christoph Schranz

Reputation: 915

It happened to me that it did not work for one internet connection (ZTE WLAN router). After switching to another one it worked. Specifying the user did not help in the first case. Unfortunately, I don't know how to debug the actual issue, but maybe this information helps someone else.

$ git push
Enumerating objects: 34, done.
Counting objects: 100% (34/34), done.
Delta compression using up to 16 threads
Compressing objects: 100% (21/21), done.
Writing objects: 100% (21/21), 3.11 KiB | 52.00 KiB/s, done.
Total 21 (delta 16), reused 0 (delta 0)
error: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400
fatal: the remote end hung up unexpectedly
fatal: the remote end hung up unexpectedly
Everything up-to-date

Upvotes: 2

Georgios Syngouroglou
Georgios Syngouroglou

Reputation: 19984

You may try to use the upstream (tracking) reference in your git command, by adding the -u option.

git push -u origin master

Upvotes: 2

Andrey Chinov
Andrey Chinov

Reputation: 44

I faced the same error. I had a task to move from one server to another (TFS to Azure), all the repositories, except one, were easily moved using THIS procedure. One repository, when trying to make a PUSH, threw out such an error. There are about 15 branches in this repository. I decided to transfer one branch at a time, using git push url://to/new/repository.git branch-to-move:new-branch-name. When I applied this option to the master branch, I got the same error. Then I transferred all other branches (there were no problems with them). After that, the master branch migrated without problems.

Upvotes: 2

Related Questions