我能夠通過https://github.com/創建一個倉庫(比如repo
),並具有:如何在GitHub中創建嵌套的存儲庫?
https://github.com/username/repo.git
如何創建另一個存儲庫(比如sub_repo
)置於repo
之下,果然有:
https://github.com/username/repo/sub_repo.git
我能夠通過https://github.com/創建一個倉庫(比如repo
),並具有:如何在GitHub中創建嵌套的存儲庫?
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_repo.git
的sub_repo模塊將被鏈接到父回購,可以在sub_repo目錄中找到。
提交(.gitmodules和sub_repo),推,你就完成了。
github不支持嵌套存儲庫。如果你不想擁有子模塊的絕對URL,那麼這個自定義就是把它們放在超級版本庫旁邊,並在URL中使用「../」,如下所示:https://github.com/losalamos/cinch-nested-example/blob/d59c26a89153148ba29d68dd5ee455a88efbc9a2/.gitmodules
如何創建'username/repo/sub -repo.git'而不是'username/sub-repo.git'?我的目的是很好地組織我的代碼。 – SparkAndShine
對不起,修正了一個錯字。 sub_repo是一個普通的存儲庫 - threre是無法在github上使用嵌套文件夾的。 – MrTux
Git Subtree可以實現這個嗎? – SparkAndShine