添加无法从索引中删除的子模块

Rui*_*ves 22 git git-submodules

我正在尝试添加一个已经存在的子模块(不同的git远程存储库).由于我没有在如何正确地进行搜索之前进行搜索,我认为我已经弄乱了我的存储库,我需要一些帮助才能再次修复它.

我已经删除了.gitmodules和.git/config中有关我要删除的子模块的所有相关部分.我还验证了.git /目录中没有modules目录.

但是,当我运行该命令时git rm --cached path_to_submodule,将显示以下消息:

fatal: pathspec 'path_to_submodule' did not match any files

由于上一个命令失败,当我尝试再次使用新定义添加相同的子模块时,运行该命令git submodule add gituser@host:repo.git,这是显示的消息:

'repo' already exists in the index

Von*_*onC 49

'repo' already exists in the index可以显示message()的唯一方法是,如果索引中仍然存在'repo'(请参阅本章有关子模块):

$ rm -Rf rack/
$ git submodule add git@github.com:schacon/rack.git rack
'rack' already exists in the index

You have to unstage the rack directory first. Then you can add the submodule:

$ git rm -r rack
$ git submodule add git@github.com:schacon/rack.git rack
Run Code Online (Sandbox Code Playgroud)

即使' rack'不是子模块,如果它存在,也会阻止声明同名的子模块.


Gut*_*Mac 11

如果添加新子模块的输出是:

'FolderName' already exists in the index
Run Code Online (Sandbox Code Playgroud)

提示下一个命令

git ls-files --stage 
Run Code Online (Sandbox Code Playgroud)

输出将类似于:

160000 d023657a21c1bf05d0eeaac6218eb5cca8520d16  0  FolderName
Run Code Online (Sandbox Code Playgroud)

然后,删除文件夹索引提示:

git rm -r --cached FolderName
Run Code Online (Sandbox Code Playgroud)

再次尝试添加子模块