Git clone all but one file or folder, possible? [duplicate]

纵然是瞬间 提交于 2019-12-11 08:12:47

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!