【问题标题】:No submodule mapping found in .gitmodules for path and missing .gitmodules file在 .gitmodules 中找不到路径的子模块映射并且缺少 .gitmodules 文件
【发布时间】:2013-06-10 05:25:23
【问题描述】:

当我运行git submodule init 时,我收到以下错误:

在 .gitmodules 中找不到路径 'xxx' 的子模块映射

我搜索了一个.gitmodules 文件,但在任何地方都找不到。

我已经阅读了this 关于同一主题的最流行的 SO 问题。 但不幸的是,我无法解决问题。特别是考虑到我不再拥有.gitmodules

根据我的 GitHub 私人仓库,我的仓库仍然有子模块。只是我在任何地方都找不到.gitmodules 文件。

【问题讨论】:

  • 我认为可能值得注意的是,如果您在现有存储库(“子模块”的定义)中 git init 一个新的存储库,您可能会意外创建一个子模块。如果这样做,将不会创建 .gitmodule 文件。

标签: git git-submodules


【解决方案1】:
  1. 确保.git/config 中没有submodule 部分。如果有,请将其删除。
  2. git rm --cached <path_to_submodule>

【讨论】:

  • 上面的第 2 步对我来说已经足够了; git rm --cached .
  • 第二步后别忘了git commit
  • 调用git rm --cached 得到fatal: Please, stage your changes to .gitmodules or stash them to proceed
  • @QuolonelQuestions 我也知道了..git add .gitmodules 将暂存文件,然后git rm --cached <submodule_path> 为我工作。
  • 这对我也有用。我正处于一个变基的中间,仍然能够使用这个答案。
【解决方案2】:

昨天刚刚解决了同样的问题,在手动删除.gitmodules中的条目(例如nano .gitmodules)之后,我不得不选择

git rm --cached <pathtomodule> 

它返回了一条消息

rm '<pathtomodule>'

然后我需要一个

git commit -m "delete cached modules"

并验证子模块删除。

【讨论】:

    【解决方案3】:

    除了上述之外,我还必须删除.gitmodules

    【讨论】:

    • 在我的情况下,我没有删除整个文件,而是删除了现在无效的条目,事情又开始工作了。谢谢!
    猜你喜欢
    • 2013-01-21
    • 2016-07-18
    • 1970-01-01
    • 2021-07-27
    • 1970-01-01
    • 2012-06-30
    • 1970-01-01
    • 1970-01-01
    • 2013-06-30
    相关资源
    最近更新 更多