7

I found many questions with this error during cloning. But I get this while pushing to remote.

About my remote repo: Contains a lot of small files (a dataset).
Internet connection: I am behind my college network with decent speed (~10MBps) behind a proxy. I can guarantee that the proxy is not an issue.

I committed a lot of small files (more of them now). I tried to push them when I started getting this error. So I deleted all the files so to make the folder small enough after which I tried pushing it again. Now I am trying to push the small number of files(~20-30) of size ~40MB. And this shows up.

$ git push origin master               
Counting objects: 8124, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8105/8105), done.
Writing objects: 100% (8124/8124), 2.64 GiB | 539.00 KiB/s, done.
Total 8124 (delta 27), reused 8091 (delta 18)
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Everything up-to-date

Also, when I committed, a lot of those files were in delete mode which seems right to me as I committed them earlier. Now my files are ~40MB and my .git folder is ~6GB.

I would be very grateful if someone can help resolve the issue.

subtleseeker
  • 4,415
  • 5
  • 29
  • 41
  • Possible duplicate of [Git fails when pushing commit to github](https://stackoverflow.com/questions/2702731/git-fails-when-pushing-commit-to-github) – Tomasz Noinski Apr 23 '19 at 20:54
  • Have you got some really big files in your commit history, such as 100MB or bigger? Are you using a proxy, such as HAProxy? – Lasse V. Karlsen Apr 23 '19 at 22:23
  • This error means your connection was truncated at some point; something on the network is causing the connection to be dropped. Very frequently when a proxy is involved, it's the proxy. Try from a different network without the proxy. – bk2204 Apr 23 '19 at 23:13
  • @LasseVågsætherKarlsen Yes, in the earlier commit, some large files were there. But I removed them now. While committing, I see those files in delete mode. I am behind an LDAP proxy. – subtleseeker Apr 24 '19 at 08:07
  • @bk2204 I am previously pushed such files. I am quite sure, it's not about proxy. – subtleseeker Apr 24 '19 at 08:08
  • If you have them in the history, and they're above 100MB, you may not be able to push your repository until you have removed them completely from history. Github have size limitations. – Lasse V. Karlsen Apr 24 '19 at 11:13

4 Answers4

8

Try with a different push size, meaning:

Cancel the last commit with git reset @~.

Then add only a small set of file, commit and try to push those.
Repeat for the other files.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    This is the only thing that worked for me. I replaced the @~ in the solution above with the commit code of the second last commit and then staged, committed and pushed smaller batches of files. – Abrie Nel May 17 '21 at 23:15
  • @AbrieNel well done. Pushing a smaller set is indeed a good option in this case. – VonC May 18 '21 at 05:04
5

increase the 'http.postBuffer' as much as is appropriate for you

git config --global http.postBuffer 524288000
Elton Sandré
  • 372
  • 3
  • 7
3

I got the same issue while pushing some code to Github.

I tried git config --global http.postBuffer 524288000 but It didn't work for me.

Reason

It was because your commit history and/or any file(s) size is bigger.

My Case

In my case, package-lock.json was causing the problem. It was 1500+KB in size and 33K lines of code.

How I solved it?

  1. I commit and pushed everything without package-lock.json
  2. Copy the content of package-lock.json.
  3. Created a new file with the name of package-lock.json from the GitHub repo page.
  4. Paste the content of package-lock.json and commit.
  5. git pull on local.

And Done.

Tips

  • Maintain each commit size smaller
  • Push frequently
  • Use a good internet connection
  • Try switching to SSH from HTTP

I hope it helped you.

Shakil Alam
  • 308
  • 4
  • 9
0

What worked for me was I canceled/reset all the commits I was trying to push

with git reset 'Commit name'.

e.g

git reset 4b8ae8f7

Then I made a new commit with all the new files and pushed

Dharman
  • 30,962
  • 25
  • 85
  • 135
Olayiwola Osho
  • 121
  • 2
  • 4