Reputation: 5830
I'm cloning the Linux kernel repository. The repository is so huge and my network is so slow that I can't clone it all at once. That may keep my computer on for a whole week.
If I stop the cloning mid-operation, progress would be lost. How can I partially clone a git repository?
Upvotes: 2
Views: 948
Reputation: 49008
A clone is actually a series of smaller steps. In a nutshell, it first downloads a list of references, then it retrieves the pack file or loose object file for each of those references. There's currently no way to resume an interrupted clone automatically, because a clone usually sends one big pack file, but with some work and research you should be able to request smaller packs manually, the same as someone who does a series of pulls over time.
Look at the git book chapter on transfer protocols and the git fetch-pack command for more information. Also, git's source code is available on github, so you may be able to add a resume option yourself, or at least use it to get an idea of how clones are done internally.
Upvotes: 0
Reputation: 60748
git clone --depth 100
will only grab the last 100 commits.
In general it looks like what you actually want is unsupported:
All kind of say "this doesn't exist yet."
But some large repos also host "dumb" http ways to retrieve the repo (not git-layer clone) to solve this problem. Linux kernel may.
Upvotes: 0
Reputation: 18402
I'm not sure what you mean by separately but git clone
is going to clone the whole repo as there is no way to clone just some part of a repo.
But you can do a shallow clone with just a depth of one commit and/or only one branch
git clone --depth=1 --single-branch --branch master
That will just grab the last commit of the master
branch.
Upvotes: 2
Reputation: 11228
Cloning cannot be resumed, if it's interrupted you'd need to start over. There can be a couple of workaround though:
You can use shallow clone i.e. git clone --depth=1
, then you can deepen this repository using git fetch --depth=N
, with increasing N. But disclaimer is, I have never tried myself.
Another option could be git-bundle. The bundle itself is a single file, which you can download via HTTP or FTP with resume support (via BitTorrent, rsync or using any download manager). You can have somebody to create a bundle for you and then download it and create a clone from that. Correct the configuration and next of fetch from the original repo.
Upvotes: 5