Git Connection Errors During Cloning
I got these errors recently when I was trying to clone one of our repos. Unstable network connection or network infrastructure may have caused this so as a workaround, you can clone the repo “bit-by-bit”.
$ git clone ssh://git@your.host.com/yourrepo.git
Cloning into 'projectdir'...
...
remote: Enumerating objects: 26639, done.
remote: Counting objects: 100% (269/269), done.
remote: Compressing objects: 100% (152/152), done.
client_loop: send disconnect: Connection reset by peer6 MiB/s
fetch-pack: unexpected disconnect while reading sideband packet
fatal: fetch-pack: invalid index-pack output
$ git clone ssh://git@your.host.com/yourrepo.git
Cloning into 'projectdir'...
...
remote: Enumerating objects: 26639, done.
remote: Counting objects: 100% (269/269), done.
remote: Compressing objects: 100% (152/152), done.
client_loop: send disconnect: Connection reset by peer9 MiB/s
fatal: early EOF
fatal: fetch-pack: invalid index-pack outputing sideband packet
Workaround
The workaround is to checkout the repo bit-by-bit.
Disable Compression
Not sure how this exactly helps but some users in the stackoverflow reference claim that this actually fixed their error. No harm in trying. You will enable it again in the succeeding steps.
git config --global core.compression 0
Clone the Repo
Now, clone the repo using a depth of 1.
git clone --depth 1 <repo_URI>
example:
git clone --depth 1 ssh://git@your.host.com/yourrepo.git
Enable Compression
Set compression back to default.
git config --global --unset core.compression
Retrieve the Rest of the Repo
Try to retrieve the other commits.
git fetch --unshallow
Then try to fetch all branches. Note that in the command below, it is assumed that the remote repository is named ‘origin’. You should change it to the name of your remote repository if otherwise.
git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
git fetch --all
References: