如何在GitHub中创建嵌套的存储库? [英] How do I create nested repositories in GitHub?
问题描述
我可以通过 https://github.com/ 创建存储库(比如 repo
)并且有:
https://github.com/username/repo.git
如何创建另一个存储库(比如 sub_repo
)放在 repo
下,并且预期有:
https:// github.com/username/repo/sub_repo.git
GitHub不允许使用嵌套的存储库(IIRC Git不允许使用裸存储库)。
但是,您可以使用子模块将存储库嵌套到客户端工作树。
您需要克隆父目录。
然后,将子存储库添加为 submodule : git submodule add https://github.com/username/sub_r epo.git
sub_repo模块将会连接到父回购站,并且可以在sub_repo中找到目录。
提交(.gitmodules和sub_repo),推送完成。
I am able to create a repository via https://github.com/ (say repo
) and have:
https://github.com/username/repo.git
How do I create another repository (say sub_repo
) placed under repo
and expectedly have:
https://github.com/username/repo/sub_repo.git
GitHub does not allow nested repositories (IIRC Git doesn't allow this for bare repositories).
However, you can use submodules to nest repositories on the "client side" in the working tree.
You need to clone the parent directory.
Then, add the sub-repository as a submodule:
git submodule add https://github.com/username/sub_repo.git
The sub_repo module will then be linked to the parent repo and can be found in the sub_repo directory.
Commit (.gitmodules and sub_repo), push and you're done.
这篇关于如何在GitHub中创建嵌套的存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!