1

I have very slow access to some gits. So it is quite likely the simple "git remote update“ will fail with something like:

error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with unexpected length was received.
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
error: Could not fetch origin

Do I have a way to update only 10% of the remote git? In this way, I hope I can incremently get the whole git updated finally.

Zhang Li
  • 117
  • 1
  • 11

1 Answers1

2

You can start with a shallow clone:

git clone --depth=1 <url>

Then, as I mentioned here, you can fetch only:

In each instance, that would avoid dealing with the full history of the repository over a slow network.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    @AlicePurcell Thank you. I have restored the proper link. – VonC Feb 11 '21 at 13:16
  • Probably worth describing this as "up to a branch/tag" as shallow-exclude doesn't seem to accept commit hashes – Alice Purcell Feb 11 '21 at 13:31
  • @AlicePurcell https://git-scm.com/docs/git-fetch#Documentation/git-fetch.txt---shallow-excludeltrevisiongt says it accepts "revision". A branch or tag is a revision, but so is a commit (https://git-scm.com/docs/gitglossary#def_revision). – VonC Feb 11 '21 at 13:40
  • (a) it goes on to say "to exclude commits reachable from a specified remote branch or tag", quite specifically. (b) it definitely didn't work when I tried it ("server hung up unexpectedly"). However, if you get it working, I'd be overjoyed to be wrong :) – Alice Purcell Feb 12 '21 at 20:51
  • @AlicePurcell Strange. What version of Git are you using? I am not able to test it at the moment. A `git clone --shallow-exclude=8d884aeda07e56560044e95fd8bfdf5819b2796b https://github.com/VonC/gpr gpr2` returns `fatal: error reading section header 'shallow-info'`. It is true the tests are only using tag, not commits: https://github.com/git/git/blob/e6362826a0409539642a5738db61827e5978e2e4/t/t5539-fetch-http-shallow.sh#L109-L129 – VonC Feb 12 '21 at 22:36
  • The laptop I tried it on suffered permanent disk death on Friday so I can't check the git version any more :( I was using a git: rather than https: URL so maybe that explains the different failure mode. I definitely got it working passing in a branch to shallow-exclude — but only if the branch was in the direct history of the branch I was fetching. If they only shared a common ancestor, I got the unexpected hang-up error again. – Alice Purcell Feb 13 '21 at 23:11
  • 1
    @AlicePurcell Darn... this command is *much* more dangerous than I thought... – VonC Feb 13 '21 at 23:19