You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何清除Git中从未是子模块路径的无效引用以消除报错

解决Git子模块映射不存在的错误(路径从未作为子模块)

执行命令git submodule foreach --recursive 'git ls-remote origin && git pull origin master --ff-only || true'时出现如下错误:

fatal: no submodule mapping found in .gitmodules for path 'path/name'

该路径只是曾被克隆到仓库后又删除,从未作为子模块存在,只需清除Git仓库里的残留引用即可解决,步骤如下:

  • 清理.git/modules目录下的残留文件夹(如果存在):
    rm -rf .git/modules/path/name
    
  • 打开.git/config文件,找到以[submodule "path/name"]开头的配置段,直接删除这部分内容
  • 清除Git索引里的残留子模块记录:
    git rm --cached path/name
    
  • 提交更改完成清理:
    git commit -m "清除不存在的子模块引用 path/name"
    

内容的提问来源于stack exchange,提问作者clarkk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 10:58:11