Is there any way to continue Git clone from the point where it failed?

后端 未结 3 377
失恋的感觉
失恋的感觉 2020-12-06 04:35

I was cloning the open embedded project yesterday. Because of connection problems, the cloning failed. I started the command again and cloning started from the beginning.

相关标签:
3条回答
  • 2020-12-06 05:08

    Note: for project including submodules, git 2.9.1 (July 2016) can help.

    See commit bb9d91b (09 Jun 2016), and commit 665b35e (10 Jun 2016) by Stefan Beller (stefanbeller).
    (Merged by Junio C Hamano -- gitster -- in commit bb2d8a8, 11 Jul 2016)

    submodule--helper: initial clone learns retry logic

    Each submodule that is attempted to be cloned, will be retried once in case of failure after all other submodules were cloned.
    This helps to mitigate ephemeral server failures and increases chances of a reliable

    If the retry fails, the error message will be:

    Failed to clone '%s' a second time, aborting
    

    clone of a repo with hundreds of submodules immensely.

    0 讨论(0)
  • 2020-12-06 05:20

    Unfortunately this cannot be done. See

    • Continue interrupted git clone

      No. git clone cannot be restarted. You'll need to rm -rf common, and then restart then clone from the beginning.

    • Continue git clone after interruption

      Unfortunately, we did not have enough GSoC slots for the project to allow restartable clones.

      There were discussions about how to implement this on the list, though.

      Unfortunately, those of us who know how the native protocol works can't come to an agreement on how it might be restartable. If you really read the archives on this topic, you'll see that Nico and I disagree about how to do this. IIRC Nico's position is, it isn't really possible to implement a restart.

    You have to restart the clone.

    0 讨论(0)
  • 2020-12-06 05:24

    With poor connectivity between the git server and your local computer, a git clone may continue for many hours and then fail. Restarting the clone just restarts the process, which is likely to fail again.

    As a workaround, use a hosted server that has good connectivity to the git repository and ssh access from your local. Clone to the server, then rsync to your local over ssh, and resume the rsync as needed.

    On your cloud server:

    `git clone -n git://<repo>.git`
    

    On your local computer (if fails, repeat to resume):

    `rsync -a -P -e ssh <user>@<cloud-server>:<path-to-cloned-repository> <local-target-path>`
    
    0 讨论(0)
提交回复
热议问题