问题
Possible Duplicate:
Is there any way to clone a git repository’s sub-directory only?
Is it possible to clone a repository but some files?
Let's say I don't want to clone the example
folder, because anyway I'll delete it after.
回答1:
The short answer - No. Git clone will always clone the complete file structure.
If you want to minimise the amount of data over the network you can use
git clone --depth 1
.
To achieve what you are asking for:
mkdir repo
cd repo
git init
git remote add -f origin $URL
git config core.sparseCheckout true
echo '$DIRNAME' >> .git/info/sparse-checkout # Do this for every directory you want.
git fetch
git checkout $BRANCH # Typically master
But I think that in your case, it is probably easier to just remove the examples
directory.
来源:https://stackoverflow.com/questions/14700896/git-clone-all-but-one-file-or-folder-possible