简体   繁体   English

如何在克隆一个 GIT repo 时克隆不同的 GIT Repo 的特定文件夹

[英]How to clone different GIT Repo's specific folder while cloning one GIT repo

We have multiple GIT repos and have requirement of including one subdirectory from different repo while cloning the main GIT repo.我们有多个 GIT 存储库,并且要求在克隆主 GIT 存储库时包含来自不同存储库的一个子目录。 Example: When I clone repo_1 it also should clone repo_2:/src/dev So, only one clone command will be executed "git clone -b master repo_1."示例:当我克隆 repo_1 时,它也应该克隆 repo_2:/src/dev 因此,只会执行一个克隆命令“git clone -b master repo_1”。 and it also should clone repo_2:/src/dev directory at the same time.它还应该同时克隆 repo_2:/src/dev 目录。

Is this possible to do in GIT?这可以在 GIT 中完成吗?

It is through submodules , where repo1 can reference a specific commit of repo2 , which will be checked out as a subdirectory of repo1 .它是通过子模块,其中repo1可以引用repo2的特定提交,它将作为repo1子目录签出。
Using a script like Reedbeta/git-partial-submodule can help making sure repo2 is using a sparse checkout, in order to deliver only its src/dev content instead of the full repository.使用像Reedbeta/git-partial-submodule这样的脚本可以帮助确保 repo2 使用稀疏签出,以便仅提供其src/dev内容而不是完整的存储库。

What is not possible, as far as I know, is to have both repositories checked out in the same local folder.据我所知,不可能在同一个本地文件夹中检出两个存储库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM