Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

Is there any way to start my clone from the point where it failed?

like image 969
snr Avatar asked Dec 21 '11 09:12

snr


People also ask

Can you pause git clone?

Depending on your situation (e.g. if you want to close your laptop and / or switch networks), stopping the process (using Ctrl-Z ) and resuming it (using fg ) might work for you. This worked for me, and i have been doing that... stop the process, put the PC into hibernation and resume the process.

Can I clone the same repo twice?

Simply clone your project's repo twice (or even more often). When your work on a feature branch is done, simply push that branch and check it out on your 2nd copy to run tests there. You can pick up a new story and work on that on your "main" project directory.

Does git clone get all history?

Cloning an entire repo is standard operating procedure using Git. Each clone usually includes everything in a repository. That means when you clone, you get not only the files, but every revision of every file ever committed, plus the history of each commit.


2 Answers

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.

like image 75
First Zero Avatar answered Oct 12 '22 04:10

First Zero


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>` 
like image 25
Jeffrey Urban Avatar answered Oct 12 '22 03:10

Jeffrey Urban