git push fails - fatal: the remote end hung up unexpectedly
Asked Answered
A

4

9

I created a git repo locally. When I try to push to github, I get:

Warning: Permanently added the RSA host key for IP address '140.82.112.4' to the list of known hosts.
Enumerating objects: 47, done.
Counting objects: 100% (47/47), done.
Delta compression using up to 8 threads
Compressing objects: 100% (39/39), done.
Writing objects: 100% (47/47), 756.22 KiB | 9.11 MiB/s, done.
Total 47 (delta 7), reused 0 (delta 0), pack-reused 0
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly
client_loop: send disconnect: Broken pipe

When I run git remote -v:

origin  [email protected]:crwils/react_unit_and_cypresstesting.git (fetch)
origin  [email protected]:crwils/react_unit_and_cypresstesting.git (push)

Tried increasing the git buffer size:

git config --global http.postBuffer 157286400

Based on various other, similar issues/solutions found on here, I've also tried:

  • git repack
  • deleting and creating a new SSH Key
  • deleting the .git file and reinitializing the repo then pushing
  • deleting the .git file, moving all files to new folder, initializing a new repo locally, then pushing to a new remote repo on github
  • changing to a different internet connection

This just started happening with some existing as well as new repo's, but not others, no theme apparent.

Can anybody help please?

Allhallowmas answered 11/5, 2021 at 21:20 Comment(2)
http.postbuffer has no effect on SSH and should not be used unless you are certain you need it. When it fixes a problem, it indicates that the remote server or your network is noncompliant with standards written in 1999 and should be fixed.Ld
Your problem is likely some sort of network problem, though. Besides standard network issues, proxies and non-default antivirus and firewall programs can be a source of this kind of problem.Ld
B
8

Check first if using HTTPS instead of SSH would work: that would isolate the issue on SSH port 22.

cd /path/to/react_unit_and_cypresstesting
git remote set-url https://github.com/crwils/react_unit_and_cypresstesting.git
git push

You will have to enter your GitHub username/password, but they can be cached in a credential helper.

Beera answered 12/5, 2021 at 7:50 Comment(14)
Thanks Von, so I tried this and it works fine when changing to HTTPS. So it's SSH that is the issue?Allhallowmas
@Craig Yes. For instance, in a corporate environment, I would not be able to use SSH for sure.Beera
I see, thank you for the help. I actually just tried going back to SSH from HTTPS and it seems to have worked, using git remote set-url origin [email protected]:crwils/vu_app_project.git. Is there anything I might be able to do to fix the SSH issue?Allhallowmas
@Craig Does ssh -Tv [email protected] works?Beera
It seems to run fine, then ends with the below. The SSH issue still exists when trying to push a repo to github without switching to and from HTTPS first though. You've successfully authenticated, but GitHub does not provide shell access. debug1: channel 0: free: client-session, nchannels 1 Transferred: sent 3452, received 2868 bytes, in 0.2 seconds Bytes per second: sent 15588.6, received 12951.4 debug1: Exit status 1Allhallowmas
@Craig Would pushing a small commit (small set of small files) work in SSH?Beera
yes it seems to work when just a small set of files. I tried with just an app.js file for example, and it worked in SSH first time. With larger sets of files it doesn't seem to work.Allhallowmas
@Craig OK, strange. Maybe enabling TRACE2 will give more clues (git-scm.com/docs/api-trace2#_enabling_a_target, devblogs.microsoft.com/devops/…): In your case GIT_TRACE2_EVENT, that I mention in https://mcmap.net/q/12679/-how-can-i-debug-git-git-shell-related-problemsBeera
I have been having this issue for weeks, after using ssh for years? Something must have changed within the github infrastructure to cause this my2cLanguorous
@Languorous do you also push to github as in the OP? Or is it about another remote Git repository hosting service (like GitLab)?Beera
@Beera do not understand term OP- github is my only provider for these repos. I also push to bitbucket, theoretically, but never with these repos and not for the last couple of years. This new behavior came up about a month ago? and for every one of the dozen or more repos that I push to frequently.Languorous
@Languorous OP: original post, or poster: en.m.wikipedia.org/wiki/Internet_forum#ThreadBeera
I changed it the url from .git/config file in may project folder.Anthropologist
@Anthropologist Yes, that is what git remote set-url does: modify the URL in the local Git repository config file (the .git/config indeed)Beera
P
1

I've been through the ringer with this one on multiple versions of windows. It only occurs on my laptop, and over wifi. The only solution I found working, after trying every command line solution on stackoverflow is to figure out your exact wireless card model, and downloading the latest drivers for it. Uninstall the device and remove original driver before attempting.

Good luck!

Putamen answered 6/11, 2023 at 21:16 Comment(0)
A
0

The only solution for this was to use HTTPS first, then switch to SSL e.g.

git remote set-url origin [HTTPS: https://github.com/username/your-repo-name]
git remote set-url origin [SSH: [email protected]:username/your-repo-name]
Allhallowmas answered 22/11, 2021 at 19:28 Comment(2)
Please mark VonC's answer as the correct answer. Thanks.Durante
I second this answer--VonC was correct but the issue wasn't fixed for me until I followed both these steps.Counterpoison
C
0

This was happening for me because the remote Github branch I had branched off was deleted and the corresponding pull request had been merged into main and closed.

Fixed by rebasing on main & doing another git push.

Contraction answered 23/11, 2023 at 4:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.