[英]How to initialize git submodule when you already have a local copy?
I already have a git repo inside another one. 我已经在另一个里面有一个git repo。 Let's say the directory structure is:
假设目录结构为:
repo1
--.git
--repo2
--.git
How would I be able to tell git I want repo2 to be a submodule? 我怎样才能告诉git我希望repo2成为子模块? Note that I already have the entire git repo on disk (I tried doing
git submodule add repo2
, but it said repo URL: 'repo2' must be absolute or begin with ./|../
) 请注意,我已经在磁盘上拥有了整个git repo(我尝试在
git submodule add repo2
,但是它说了repo URL: 'repo2' must be absolute or begin with ./|../
)
I believe what you want is git submodule add <URL> repo2
. 我相信你想要的是
git submodule add <URL> repo2
。 Essentially, you always want a remote URL to point to (think about how you initialize a git repo: git clone <repo>
. Hence, it shouldn't be different for git submodules 本质上,您始终希望远程URL指向(考虑如何初始化git repo:
git clone <repo>
。因此,对于git子模块,它应该没有什么不同
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.