136

I have only one branch. For a few months I have been using

git push origin master

to commit to my local repository. Last night after I made some minor changes to my local repository and tried to push using the same command, I got this error:

error: RPC failed; result=22, HTTP code = 411
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Everything up-to-date

I googled and found questions such as this one and this one, but none of the answers to these questions solves my problem.

Most of the answers suggest the problem of detached head. Yet I don't think my head is detached. Nor do I think I am on the wrong branch (as I only have one branch...)

I did a few experiments to figure out what's wrong, and here are the results I got:

(1) First comes my git status output

# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
# egal.aux
# egal.blg
# egal.out
# egal.pdf
# egalcar.aux
# egalcar.blg
# egalcar.pdf
nothing added to commit but untracked files present (use "git add" to track)

(2) When I type git reflog, I can see all my local commits, but the remote repository just won't get updated.

(3) When I type git branch -a, I get

* master
  remotes/origin/master

(4) When I type git remote show origin, I get

* remote origin
  Fetch URL: http://github.com/CherryQu921/egaldoc_en
  Push  URL: http://github.com/CherryQu921/egaldoc_en
  HEAD branch: master
  Remote branch:
    master tracked
  Local ref configured for 'git push':
    master pushes to master (fast-forwardable)

I think the last line of output (the "fast-forwardable") is weird, but I am not sure what is wrong...

1
  • fast-forwardable means you can push your local changes to the remote branch, nothing criminal :-) Commented Sep 29, 2012 at 10:15

6 Answers 6

317

If you attempt to push a large set of changes to a Git repository with HTTP or HTTPS, you may get an error message such as error: RPC failed; result=22, HTTP code = 411. This is caused by a Git configuration default which limits certain HTTP operations to 1 megabyte.

To change this limit run within your local repository

git config http.postBuffer *bytes*

where bytes is the maximum number of bytes permitted. For example:

git config http.postBuffer 524288000

For 500MB (thanks @Hengjie)

4
  • 54
    An example is git config http.postBuffer 524288000 for 500MB.
    – Hengjie
    Commented Feb 6, 2013 at 22:40
  • 10
    If you are using gitlab, you may need to change your nginx config too (/etc/nginx/sites-available/gitlab). More info: github.com/gitlabhq/gitlabhq/issues/3099
    – DanielB
    Commented Dec 12, 2013 at 3:54
  • what if it shows RPC failed; result=22, HTTP code = 502? Commented Jul 22, 2015 at 3:48
  • 2
    I am still getting following error git: RPC failed; result=22, HTTP code = 504 in bitbucket on android studio
    – DJtiwari
    Commented Nov 3, 2015 at 9:53
26

You can also do this globally -

git config --global http.postBuffer 524288000

That will allow all local repos to push up to 500MB of data.

4

None of the solutions provided worked for us. We had to switch to ssh to make this work instead of the HTTPS solution.

2

If you are using TortoiseGit for Windows, the easiest way is using the integrated configuration.

In a file explorer press left mouse button, select TortoiseGit -> Settings. Accept the info message. Now, you can choose if you want to configure the property only for the current project or system whide. For systemwide configuration press "edit systemwide gitconfig" and add the next line to the section [http]:

postBuffer = 524288000

(it the section [http] doesn't exist, create it)

1

I solved the 22 error as follows: In the "git clone" command I did NOT supply the user:password. The clone worked, but not the push. Solution for the 22 error: Modify .git/config the url like this: url=http://user:pwd@host/... Then, the push worked.

-1

use git lfs and track files greater than 1 mb and then again try to push

1
  • this isn't going to help them, doesn't show them how to use git lfs, and doesn't deal with what might already be in the repo.
    – UpAndAdam
    Commented Apr 4 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.