No submodule mapping found in .gitmodules for path ......

问题现象

在执行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 <file>..." 撤出暂存区)
#
#	删除:      thirdparty-tools/.github.com/gogo/protobuf
#	删除:      thirdparty-tools/.golang.org/x/tools
  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值