ped*_*umj 5 git clone git-clone git-submodules
我在父文件夹中有一个 git 存储库。我们将此文件夹称为“根”。然后该文件夹中有一个子目录,我们称之为“child”。我想要做的是将远程存储库作为子模块克隆到“child”中:
git submodule add git@github.com:username/repopath child/
git submodule add git@github.com:username/repopath ./child/
Run Code Online (Sandbox Code Playgroud)
以上都给了我错误:
子项已存在于索引中
我尝试将目录从跟踪中删除:
git rm --cached .\child\*
git submodule add git@github.com:username/repopath child/
Run Code Online (Sandbox Code Playgroud)
然后我得到这个错误:
“child”已经存在并且不是有效的 git 存储库
非常感激任何的帮助
谢谢
首先,在新克隆中尝试子模块添加命令,因为您之前的尝试可能为子模块留下了部分状态。
二、先尝试
git rm -r --cached child
Run Code Online (Sandbox Code Playgroud)
然后,添加并提交。
最后,尝试你的git submodule命令:
git submodule add -- git@github.com:username/repopath child
Run Code Online (Sandbox Code Playgroud)
添加并提交。