除了一个文件或文件夹,Git克隆可能吗? [英] Git clone all but one file or folder, possible?

查看:264
本文介绍了除了一个文件或文件夹,Git克隆可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆