在执行git submodule init 或 git submodule update的时候会报在map找不到路径的错误如下:
[root@centos7]#git submodule init No submodule mapping found in .gitmodules for path 'thirdparty-tools/.github.com/gogo/protobuf'问题原因
发现有工程里面,有不在 .gitmodule 文件中的 submodule 需要更新
通过如下命令查看
git ls-files --stage | grep 160000
[root@centos7]git ls-files --stage | grep 160000 160000 30cf7ac33676b5786e78c746683f0d4cd64fa75b 0 thirdparty-tools/.github.com/gogo/protobuf 160000 fd2d2c45eb2dff7b87eab4303a1016b4dbf95e81 0 thirdparty-tools/.golang.org/x/tools解决方法
就是不在.gitmodule 文件中的 submodule删除掉,就是上面列出的路径
执行如下命令进行删除
git rm --cached path
#删除操作 [root@centos7]# git rm --cached thirdparty-tools/.github.com/gogo/protobuf rm 'thirdparty-tools/.github.com/gogo/protobuf' [root@centos7]# git rm --cached thirdparty-tools/.golang.org/x/tools rm 'thirdparty-tools/.golang.org/x/tools' # 再执行git submodule init 能成功 [root@centos7]# git submodule init [root@centos7]#
如果通过 git status能够查看删除操作
git status .... # 要提交的变更: # (使用 "git reset HEAD..." 撤出暂存区) # # 删除: thirdparty-tools/.github.com/gogo/protobuf # 删除: thirdparty-tools/.golang.org/x/tools



