細い回線でgit cloneに失敗

細めの回線でgit cloneに失敗することがよくあります.
例えばこんな.

$ git clone https://github.com/ergochat/ergo
Cloning into 'ergo'...
remote: Enumerating objects: 26435, done.
remote: Counting objects: 100% (620/620), done.
remote: Compressing objects: 100% (163/163), done.
error: RPC failed; curl 18 transfer closed with outstanding read data rem
aining
error: 3971 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output

とかこんな

$ git clone https://github.com/ghostty-org/ghostty --depth=1
Cloning into 'ghostty'...
remote: Enumerating objects: 914, done.
remote: Counting objects: 100% (914/914), done.
remote: Compressing objects: 100% (833/833), done.
error: RPC failed; curl 56 GnuTLS recv error (-9): Error decoding the received TLS packet.
error: 3243 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output

git configで以下のような設定で多少ましになりますがそれでも同じリポジトリでも成功したり失敗したりと安定しません.

http.version=HTTP/1.1
http.postbuffer=524288000

clone時に --depth 1 を指定して fetch で段階的に取得することでうまく行くこともありますが面倒.更に試行錯誤で結構データ量も消費してしまいます.

$ git clone http://example.com/large-repository --depth 1 (1)
$ cd large-repository
$ git fetch --depth=64 (2)
$ git fetch --depth=128
$ git fetch --depth=192
$ git fetch --depth=256
   :
$ git fetch --unshallow (3)
  1. 最新1世代だけclone

  2. 最新から64世代clone

  3. 残り全てclone

でも安定しないし毎回試行錯誤が必要なので手元の環境では結局リモートのVPS等で取得してrsyncなどで同期するのが確実です.

oracleの無料なCloud Free TierのVPSでgit cloneしてrsync
$ ssh oracle-arm "git -C /tmp/ clone https://github.com/ergochat/ergo" && \
  ssh rsync -avcP /tmp/ergo . && \
  ssh oracle-arm "rm -r /tmp/ergo"

もしくは太い回線のある場所に移動してclone.自分の場合は自宅の隣のmobile cellやJoyfullです.

ちなみにこの症状の出る回線は最大7Mbpsほどのモバイル回線で,MVNOを使っているのも利いていそうです.
LTE]

StarLinkも気になりますが山に囲まれ散るのでうまく電波を掴めるかが不安です.30日以内なら返品可能なようですが…….

30 DAY TRIAL
If not satisfied, return Starlink for a full refund.

環境
$ git version
git version 2.45.2
$ dpkg-query -W git
git     1:2.45.2-1.3
$ lsb_release -dr
Description:	Debian GNU/Linux trixie/sid
Release:	n/a
$ arch
x86_64

One thought to “細い回線でgit cloneに失敗”

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)