我在父文件夹中有一个 git 存储库。让我们将此文件夹称为“根”。
然后文件夹中有一个子目录,我们称之为“子”。我想要做的是将远程存储库作为子模块克隆到“子”中:
git submodule add git@github.com:username/repopath child/
git submodule add git@github.com:username/repopath ./child/
以上都给了我错误:
child already exists in the index
我尝试从被跟踪中删除目录:
git rm --cached .\child\*
git submodule add git@github.com:username/repopath child/
然后我得到这个错误:
'child' already exists and is not a valid git repo
非常感激任何的帮助
谢谢
最佳答案
首先,在新的克隆中尝试您的 submodule add 命令,因为您之前的尝试可能为子模块留下了部分状态。
二、先试试
git rm -r --cached child
然后,添加并提交。
最后,试试你的
git submodule
command :git submodule add -- git@github.com:username/repopath child
添加并提交。
关于git 将子模块添加到现有目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42096543/