Git fails when pushing commit to github

145,805

Solution 1

I had the same issue and believe that it has to do with the size of the repo (edited- or the size of a particular file) you are trying to push.

Basically I was able to create new repos and push them to github. But an existing one would not work.

The HTTP error code seems to back me up it is a 'Length Required' error. So maybe it is too large to calc or greated that the max. Who knows.

EDIT

I found that the problem may be files that are large. I had one update that would not push even though I had successful pushes up to that point. There was only one file in the commit but it happened to be 1.6M

So I added the following config change

git config http.postBuffer 524288000

To allow up to the file size 500M and then my push worked. It may have been that this was the problem initially with pushing a big repo over the http protocol.

END EDIT

the way I could get it to work (EDIT before I modified postBuffer) was to tar up my repo, copy it to a machine that can do git over ssh, and push it to github. Then when you try to do a push/pull from the original server it should work over https. (since it is a much smaller amount of data than an original push).

Solution 2

If this command not help

git config http.postBuffer 524288000

Try to change ssh method to https

git remote -v
git remote rm origin 
git remote add origin https://github.com/username/project.git

Solution 3

Looks like a server issue (i.e. a "GitHub" issue).
If you look at this thread, it can happen when the git-http-backend gets a corrupted heap.(and since they just put in place a smart http support...)
But whatever the actual cause is, it may also be related with recent sporadic disruption in one of the GitHub fileserver.

Do you still see this error message? Because if you do:

  • check your local Git version (and upgrade to the latest one)
  • report this as a GitHub bug.

Note: the Smart HTTP Support is a big deal for those of us behind an authenticated-based enterprise firewall proxy!

From now on, if you clone a repository over the http:// url and you are using a Git client version 1.6.6 or greater, Git will automatically use the newer, better transport mechanism.
Even more amazing, however, is that you can now push over that protocol and clone private repositories as well. If you access a private repository, or you are a collaborator and want push access, you can put your username in the URL and Git will prompt you for the password when you try to access it.

Older clients will also fall back to the older, less efficient way, so nothing should break - just newer clients should work better.

So again, make sure to upgrade your Git client first.

Share:
145,805
Stephen Melvin
Author by

Stephen Melvin

Updated on July 08, 2022

Comments

  • Stephen Melvin
    Stephen Melvin almost 2 years

    I cloned a git repo that I have hosted on github to my laptop. I was able to successfully push a couple of commits to github without problem. However, now I get the following error:

    Compressing objects: 100% (792/792), done.
    error: RPC failed; result=22, HTTP code = 411
    Writing objects: 100% (1148/1148), 18.79 MiB | 13.81 MiB/s, done.
    Total 1148 (delta 356), reused 944 (delta 214)
    

    From here it just hangs and I finally have to CTRL + C back to the terminal.

    • Cascabel
      Cascabel about 14 years
      Why is there an HTTP error? Don't you push to github through SSH?
    • Cascabel
      Cascabel about 14 years
      To clarify: the url in the origin section of .git/config doesn't say http, does it?
    • Stephen Melvin
      Stephen Melvin about 14 years
      @Jefromi I cloned my private repo using the read/write http link.
    • Stephen Melvin
      Stephen Melvin about 14 years
      No, it says https. This is weird because I've been able to do two pushes prior to the failure.
  • Emaad Ahmed Manzoor
    Emaad Ahmed Manzoor over 13 years
    Worked for me too, though I had an HTTP 501 error rather than the 411. Thanks!
  • Jake
    Jake almost 12 years
    Thanks! this worked, and even speed up the upload. Was trying to push a website to the new Windows Azure Websites and it kept failing.
  • Yves Martin
    Yves Martin almost 12 years
    I got similar troubles behind a ADSL wireless router (French Orange Livebox): impossible to publish my SSH key at github.com, push stuck over https... until I use an alternate internet access.
  • snogglethorpe
    snogglethorpe over 11 years
    Is there a downside to just setting this value very high?
  • Boggin
    Boggin about 11 years
    The Smart HTTP Support managed to get me through our firewall proxy when I was getting "error: RPC failed; result=22, HTTP code = 0" when I tried to push.
  • VonC
    VonC about 11 years
    @Boggin Yes, I confirm smart http is generally the preferred choice when one is behind a proxy. The standard http/https port are (almost) always opened.
  • hemp
    hemp about 6 years
    @snogglethorpe Potentially: "Transfer-Encoding: chunked is used to avoid creating a massive pack file locally". If you set the value to something huge, you can end up generating massive pack files when you attempt to push. Not all filesystems handle massive files well and they may not prune efficiently. You can see these files in .git/objects/pack.
  • Swatantra Kumar
    Swatantra Kumar about 6 years
    Changing the http.postBuffer is more unnecessary than harmful, but there is a negative side effect: Increasing it above the default may increase latency for larger pushes (since the client will buffer the HTTP request into larger chunks).
  • Asclepius
    Asclepius over 3 years
    The number of 100000000 that you noted is basically 100 MB which is hardly astronomical.
  • Asclepius
    Asclepius over 3 years
    @snogglethorpe I have written an answer on a different thread attempting to note why this value can be as high as 2000000000 (2 GB).
  • Vishism
    Vishism almost 3 years
    Worked perfectly for me too.