问题
I want download only 2 folders from remote git repository. In this case is the ubuntu kernel git repository.
Download all kernel is a waste of time and bandwidth if I only want 2 folders.
Is there any way to do this with git?
回答1:
No you can't create a partial clone
回答2:
No, not in the way you're asking. But you can do one of these:
- download a tarball -- the repository's web-ui should offer such an option, otherwise you can use
git archive(man page, google and SO will help you with its usage); or - do a shallow clone, using the --depth switch; this will download only the given number of commits, so you don't get the whole history. The git clone manpage has more details about it.
回答3:
It seems Git CANNOT implement this.
I thought "Sparse Checkout" will works, but as @ HolgerJust said:
This will still download the full remote repository. It just doesn't checkout all the files into the working copy, but they are still available in the local index.
He's right.
Yes, you can. You can use Sparse Checkout.
Here's a simple example:
$ mkdir destinationFolder
$ cd destinationFolder
$ git init
$ git remote add origin git@github.com:Kjuly/iPokeMon.git
$ git config core.sparseCheckout true
$ echo 'Pokemon/Models/*' > .git/info/sparse-checkout
... echo more if you need
$ git pull origin dev
And finally, you'll get files:
destinationFolder
- Pokemon
- - Models
来源:https://stackoverflow.com/questions/14526760/is-possible-clone-only-a-folder-from-remote-repository