8

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  git@github.com:crwils/react_unit_and_cypresstesting.git (fetch)
origin  git@github.com: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?

crwils
  • 631
  • 1
  • 7
  • 11
  • 2
    [`http.postbuffer`](https://git-scm.com/docs/gitfaq#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. – bk2204 May 11 '21 at 23:35
  • 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. – bk2204 May 11 '21 at 23:54

2 Answers2

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks Von, so I tried this and it works fine when changing to HTTPS. So it's SSH that is the issue? – crwils May 12 '21 at 17:45
  • @Craig Yes. For instance, in a corporate environment, I would not be able to use SSH for sure. – VonC May 12 '21 at 17:52
  • 1
    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 git@github.com:crwils/vu_app_project.git`. Is there anything I might be able to do to fix the SSH issue? – crwils May 12 '21 at 19:42
  • @Craig Does `ssh -Tv git@github.com` works? – VonC May 12 '21 at 20:18
  • 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 1` – crwils May 13 '21 at 17:03
  • @Craig Would pushing a small commit (small set of small files) work in SSH? – VonC May 13 '21 at 19:54
  • 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. – crwils May 16 '21 at 20:29
  • @Craig OK, strange. Maybe enabling TRACE2 will give more clues (https://git-scm.com/docs/api-trace2#_enabling_a_target, https://devblogs.microsoft.com/devops/a-deep-dive-into-git-performance-using-trace2/): In your case `GIT_TRACE2_EVENT`, that I mention in https://stackoverflow.com/a/56094711/6309 – VonC May 16 '21 at 21:09
  • I have been having this issue for weeks, after using ssh for years? Something must have changed within the github infrastructure to cause this my2c – petecarapetyan May 27 '21 at 00:44
  • @petecarapetyan do you also push to github as in the OP? Or is it about another remote Git repository hosting service (like GitLab)? – VonC May 27 '21 at 07:24
  • @VonC 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. – petecarapetyan May 28 '21 at 10:34
  • @petecarapetyan OP: original post, or poster: https://en.m.wikipedia.org/wiki/Internet_forum#Thread – VonC May 28 '21 at 10:54
  • I changed it the url from `.git/config` file in may project folder. – M.Bakhshipour Jan 02 '23 at 12:33
  • @M.Bakhshipour Yes, that is what `git remote set-url` does: modify the URL in the local Git repository config file (the `.git/config` indeed) – VonC Jan 02 '23 at 12:53
1

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: git@github.com:username/your-repo-name]
crwils
  • 631
  • 1
  • 7
  • 11