我能通过https://github.com/(假设为repo
)创建一个仓库,并拥有:
https://github.com/username/repo.git
我该如何创建另一个仓库(例如sub_repo
)放置在repo
下,并期望具有以下效果:
https://github.com/username/repo/sub_repo.git
我能通过https://github.com/(假设为repo
)创建一个仓库,并拥有:
https://github.com/username/repo.git
我该如何创建另一个仓库(例如sub_repo
)放置在repo
下,并期望具有以下效果:
https://github.com/username/repo/sub_repo.git
GitHub不允许嵌套存储库(如果我没记错,Git不允许裸存储库这样做)。
但是,您可以使用子模块在“客户端”工作树中嵌套存储库。
您需要克隆父目录。
然后,将子存储库作为子模块添加:
git submodule add https://github.com/username/sub_repo.git
sub_repo模块将与父仓库链接并可在sub_repo目录中找到。
提交(.gitmodules和sub_repo),推送,就完成了。
username/repo/sub-repo.git
而不是 username/sub-repo.git
?我的目的是为了更好地组织我的代码。 - SparkAndShineGithub不支持嵌套存储库。如果您不想为子模块使用绝对URL,则通常将它们放在超级存储库旁边,并在URL中使用“../”,如此处所示:https://github.com/losalamos/cinch-nested-example/blob/d59c26a89153148ba29d68dd5ee455a88efbc9a2/.gitmodules