0

So when I've committed everything on my local branch and I'm ready to push to remote origin I will receive this error randomly:

fatal: the remote end hung up unexpectedly
remote: 
remote: ========================================================================
remote: 
remote: ERROR: user canceled the push

remote: 
remote: ========================================================================
remote: 

This really only happens when I'm trying to push to a remote branch for the first time. So for example git push --set-upstream origin feature/Project-XXXX/new-feature. This error only happens seemingly randomly.

My only solution so far is to keep reentering the command until it finally gives in and pushes it to remote. I can not remember if this happens in regular pushes but I don't believe it has.

Please help! I haven't seen an error like this anywhere else. I've tried things like git config http.postBuffer 524288000, downgrading the HTTP to 1.1 and then back to 2, but nothing works.

  • See [the Git FAQ](https://git-scm.com/docs/gitfaq#http-postbuffer) as to what `http.postBuffer` does and why you shouldn't need to set it. – bk2204 Nov 02 '22 at 21:15
  • @bk2204 True, that was [documented in Git 2.25.1 (Feb. 2020)](https://stackoverflow.com/a/6849424/6309). – VonC Nov 02 '22 at 22:06
  • Huh yeah, so it seems like raising http.postBuffer isn't a very effective solution for most push problems (even though it's the only solution posted online for this type of problem in my experience). I am beginning to wonder if it has something to do with my ISP or my network speed in general. – Rodrigo Mesta Nov 03 '22 at 16:43

1 Answers1

0

You can try and display the size of your first commit before your (first) push.

That way, you can check if that random error happens only when the first commit is quite large, which would explain why the remote can struggle processing it, especially if the network is slow to send all the data.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Sorry for taking a bit to respond but I just got a new branch I am trying to push to remote for the first time so I was able to test this out. So when I ran git for-each-ref --format='%(contents:size)', I got a long series of numbers with the largest being 841. I got this same error again but I only updated 2 lines of the code base so I don't think content size is behind this problem. I will update you when this passes and I can do a regular push to check the content size there. – Rodrigo Mesta Nov 03 '22 at 16:47
  • @RodrigoMesta OK, that was worth checking anyway. – VonC Nov 03 '22 at 20:22