[英]Git submodule prepare for sparse checkout
I have a submodule to be used with sparse checkout. 我有一个用于稀疏签出的子模块。 Without sparse checkout I'd do
没有稀疏的结帐我会做
git submodule update --init <path/to/submodule>
but how to initialize the submodule repository empty without fetching it (or fetching it, but not checking it out) yet, so I can invoke 但是如何在不获取子模块存储库的情况下将其初始化为空(或获取它,但不将其签出),所以我可以调用
cd <path/to/submodule>
git config core.sparseCheckout true
cd <../../..>
echo <subdir-to-get> .git/modules/<path/to/submodule>/info/sparse-checkout
Unfortunately 不幸
git submodule init <path/to/submodule>
does not create the repository in .git/modules/<path/to/submodule>
and the file <path/to/submodule>/.git
. 不会在
.git/modules/<path/to/submodule>
和文件<path/to/submodule>/.git
.git/modules/<path/to/submodule>
创建存储库。
You can try, as in here , to clone the submodule as normal repository first, and then use git submodule absorbgitdirs
. 您可以像在这里一样尝试首先将子模块克隆为普通存储库,然后使用
git submodule absorbgitdirs
。
By cloning first with a depth of 1, you don't get too many data: 通过首先以1的深度进行克隆,您不会得到太多数据:
git clone --depth=1 --no-checkout an/Url <path/to/submodule>
git submodule add an/Url <path/to/submodule>
git submodule absorbgitdirs
Then, you can modify the .git/modules/<path/to/submodule>/info/sparse-checkout
然后,您可以修改
.git/modules/<path/to/submodule>/info/sparse-checkout
git -C <path/to/submodule> config core.sparseCheckout true
echo 'foo/*' >>.git/modules/<path/to/submodule>/info/sparse-checkout
Finally, get only the files you want: 最后,仅获取所需的文件:
git submodule update --force --checkout <path/to/submodule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.