除了一个文件或文件夹,Git克隆可能吗? [英] Git clone all but one file or folder, possible?
问题描述
b
$ b是否可以克隆存储库,但是有些文件?
假设我不想克隆
示例
文件夹,因为无论如何我会在后面删除它。解决方案简短的回答 - 不需要
Git克隆将永远克隆完整的文件结构。 b
$ b如果要通过网络最小化数据量,可以使用
git clone --depth 1
。
要达到您的要求:
mkdir回购
cd repo
git init
git remote add -f origin $ URL
git config core.sparseCheckout true
echo'$ DIRNAME'>> .git / info / sparse-checkout#为每个需要的目录执行此操作。
git fetch
git checkout $ BRANCH#通常是
但我认为在你的情况下,删除
例子
目录可能更容易。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.解决方案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.这篇关于除了一个文件或文件夹,Git克隆可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!