0

I have a local git repository with an existing remote on my harddrive. Now I wanted to move the repository to github and following the documentation I did the following:

git remote set-url origin https://github.com/xxx/xxx.git
git push -u origin master

but I am getting errors.

[user@machine folder]$ git push -u origin master
Username: 
Password: 
Counting objects: 7398, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (2575/2575), done.
error: RPC failed; result=22, HTTP code = 0iB | 367.95 MiB/s   
fatal: The remote end hung up unexpectedly
Writing objects: 100% (7398/7398), 506.65 MiB | 367.95 MiB/s, done.
Total 7398 (delta 5083), reused 6965 (delta 4677)
fatal: The remote end hung up unexpectedly
fatal: expected ok/error, helper said '2004k¡oe>�Xx�FV.�Na�D�͂'

fatal: write error: Broken pipe

Most questions I found on stackoverflow were solved by

git config http.postBuffer 524288000

But it doesn't help me I also tried git repack which just made the error come up faster (and a bit less gibberish printed out).

Before git repack the error looked like this:

[user@machine folder]$ git push -u origin master
Username: 
Password: 
Counting objects: 7398, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (2771/2771), done.
error: RPC failed; result=22, HTTP code = 0iB | 11.89 MiB/s   
fatal: The remote end hung up unexpectedly
Writing objects: 100% (7398/7398), 506.60 MiB | 11.46 MiB/s, done.
Total 7398 (delta 5084), reused 6454 (delta 4481)
fatal: The remote end hung up unexpectedly
*�{�����@���߫��\l�|ʫ%r, helper said '2004�*U��m
                       ��EE$�%��M�l�\�yx�=�O�X.d (Y�gc�Ͷ�Ri�+�ONa���'���F�2X�P������~�,�rݐ��޾��_�,����n0��~8(��v��_�lꉋ�=C�����M�ݓYP���ЖO�e�t-����2X��s�Ϲ۱�<�o|�+�6x1�ob��v>�s��'

I am pretty desperate at this point. Does anyone know how to push a local git repository to github?

Stefan
  • 414
  • 1
  • 6
  • 17
  • Have you tried switching to the git protocol instead of https? – crea1 May 27 '15 at 08:55
  • 1
    "how to push a local git repository to github?" This is the right way to push a local git repo to github. You have something wrong. what's the size of your local repo? – Assem May 27 '15 at 08:58

1 Answers1

3

It can be due to several issues:

Repository size limit

git config http.postBuffer 524288000

This config that you have set up is simply increasing the buffer size that git will use when sending data to the web

http.postBuffer
Maximum size in bytes of the buffer used by smart HTTP transports when POSTing data to the remote system. For requests larger than this buffer size, HTTP/1.1 and Transfer-Encoding: chunked is used to avoid creating a massive pack file locally. Default is 1 MiB, which is sufficient for most requests.


Wrong remote configuration.

Try to set the remote using this command: git remote add origin https://github.com/xxx/xxx.git in addition to the set-url that you have already added.


Your proxy settings

In some proxies there is a limit on the size of the post file, since your repository is big one (>500MB) it might be the case here.


What to do?

Try to eliminate the above possible issues by eliminating them one by one

  1. Commit fewer files and try to commit them. If this is working so the problem is with the size of the pack file that is being send over the network.
  2. Clean your repository with gc --aggressive --prune=now
Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • Checking the directory sizes, the largest data is the .git/objects 91M ./.git/objects/30 162M ./.git/objects/69 163M ./.git/objects/81 512M ./.git/objects/pack 1.1G ./.git 1.1G ./.git/objects 1.2G . – Stefan May 27 '15 at 09:09
  • Pruning aggressively reduced the .git/objects to 600MB but it's still crashing – Stefan May 27 '15 at 09:18
  • I added another 0 behind the value of postbuffer (:P should be around 5GB now) and it seems to be stuck at some part of pushing (but not crashing yet). If it ever finishes I'll report back. – Stefan May 27 '15 at 09:26
  • To find out the size of your repo: `git count-objects -vH` – CodeWizard May 27 '15 at 09:40
  • I found the problem using a command posted in the 3rd answer in this thread http://stackoverflow.com/questions/5277467/how-can-i-clean-my-git-folder-cleaned-up-my-project-directory-but-git-is-sti . At some point I commited one file which was huge. Now I've reduced it's size. The huge version seems to linger on in the objects. How can I remove this huge version of the file from the history? (the link the guy posted doesn't work) – Stefan May 27 '15 at 09:47
  • 1
    You will have to use filter-branch for this task. `filter-branch` is going over each commit so you can loop over the history and delete the desired file – CodeWizard May 27 '15 at 09:56