Skip to content

The cloning process can be interrupted due to unstable network condition and cannot be resumed. #7440

Closed

Description

@takayamayukiko

The cloning process can be interrupted due to unstable network condition and cannot be resumed.

This happens a lot when we are trying to clone (download) a large project (e.g., over 100 MB) to local disk. The transmission speed initially is high, but gradually will become very low -- and usually there will be a point when the entire process stuck and then the program will throw an error -- and then the whole cloning process must be restarted, with all the previously downloaded data lost. The rate of failure increases drastically with the size of the project.

Is there a way to ensure the process be automatically resumed from the point of interruption even though we are downloading large project in an unstable network environment?

Activity

  1. tierninho commented on May 1, 2019

    @tierninho
    Contributor

    @takayamayukiko Thank you for making the suggestion! This sounds like a reasonable idea although there may be some underlying technical challenges I am not aware of, so I will let this sit for a few days to let other team members weigh in.

  2. shiftkey commented on May 6, 2019

    @shiftkey
    Member

    Is there a way to ensure the process be automatically resumed from the point of interruption even though we are downloading large project in an unstable network environment?

    Git itself doesn't support resuming after a failed clone, and for the moment I'd recommend this alternative workflow as a workaround:

    # create an empty repository locally and move into it
    $ git init some-repository
    $ cd some-repository
    # add the remote to be able to then try and fetch objects/refs
    $ git remote add origin [some-url]
    # this might fail, but you can retry this again and again until it downloads all the refs
    $ git fetch origin
    # checkout the default branch
    $ git reset origin/master --hard
    # ensure you are tracking the remote branch
    $ git branch -u origin/master

    Because of the number of manual steps here, we don't have plans to support this in the app. I'll add a note into #926 which is our proposed workflow to support retrying a failed clone, which is underway as part of #7080.

  3. zackees commented on Nov 27, 2024

    @zackees

    Is there a way to ensure the process be automatically resumed from the point of interruption even though we are downloading large project in an unstable network environment?

    Git itself doesn't support resuming after a failed clone, and for the moment I'd recommend this alternative workflow as a workaround:

    # create an empty repository locally and move into it
    $ git init some-repository
    $ cd some-repository
    # add the remote to be able to then try and fetch objects/refs
    $ git remote add origin [some-url]
    # this might fail, but you can retry this again and again until it downloads all the refs
    $ git fetch origin
    # checkout the default branch
    $ git reset origin/master --hard
    # ensure you are tracking the remote branch
    $ git branch -u origin/master

    Because of the number of manual steps here, we don't have plans to support this in the app. I'll add a note into #926 which is our proposed workflow to support retrying a failed clone, which is underway as part of #7080.

    yeah this doesn't work.

    git fetches can't be resumed.

    I can only imagine how many people around the world with bad internet connections absolutely cannot use git at all.

  4. finagolfin commented on Dec 22, 2024

    @finagolfin

    yeah this doesn't work.

    git fetches can't be resumed.

    I can only imagine how many people around the world with bad internet connections absolutely cannot use git at all.

    You're right. Whoever designed git this way is an idiot.

    Here's how I'm working around the problem for an initial clone of a large repository:

    > git clone https://github.com/big-co/big-repo.git --depth 50
    
    > cd big-repo/
    
    # Repeat this as necessary with a different number
    > git fetch --depth 1500
    
    > git fetch --unshallow
    

    The key is what to use instead of 1500 for your repo, which you can only figure out by trying different numbers. Try it with a very large number at first, to see how many objects it tries to download, say 1 million. Then keep lowering the depth number, which is completely different than the number of objects, till you get the number of objects down to 100k or whatever you feel comfortable with over your network.

    Keep downloading the repo in batches like that till you get close to the end and finish with the unshallow step to get the last batch.

  5. finagolfin commented on Dec 22, 2024

    @finagolfin

    Turns out that only gets a single branch and not all the tags, I had to do more to get those:

    > git fetch --tags
    
    > git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
    
    > git fetch origin
    

    That appears to get most everything, but no idea if there's still something missing. Apparently, replacing the first step above with git clone https://github.com/big-co/big-repo.git --depth 50 -b main --no-single-branch, where main is the name of your trunk branch you get by default anyway, would've avoided the need for the last two steps to get the remaining branches.

  6. zackees commented on Dec 23, 2024

    @zackees

    Well here's the thing, it's still all or nothing.

    What would be awesome is if we could fetch the history in parts, say the first 10 commits, then the next 10 commits... repeat.

    This doesn't seem to be possible yet.

  7. finagolfin commented on Dec 23, 2024

    @finagolfin

    Yes, that is exactly what the above command is doing, though you may want to use the --deepen flag instead of --depth. Of course, downloading any particular chunk of commits can still fail.

  8. zackees commented on Dec 23, 2024

    @zackees

    So something like this?

    git clone https://github.com/big-co/big-repo.git --deepen 50

  9. finagolfin commented on Dec 24, 2024

    @finagolfin

    No, the clone command remains the same as above, but I'm not clear if git fetch --depth 1500 gets new commits each time it's run, or simply gets the same commits over and over again. git fetch --deepen 1500 definitely gets new commits each time- it's how I just downloaded a large 3-4 GiB repo 500 MiB at a time- but only on the main branch, so the final --unshallow will get all the other branches, assuming you passed --no-single-branch to the initial clone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions