git 在 .gitmodules 中找不到路径和缺少 .gitmodules 文件的子模块映射

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17017335/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 16:22:00  来源:igfitidea点击:

No submodule mapping found in .gitmodules for path and missing .gitmodules file

gitgit-submodules

提问by Kim Stacks

When I run git submodule init, I get the following error:

当我运行时git submodule init,出现以下错误:

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

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

I searched for a .gitmodulesfile and I cannot find it anywhere.

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

I have read thismost popular SO question on the same topic. But unfortunately, I cannot solve the problem. Especially given that I no longer have .gitmodules.

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

According to my GitHub private repo, I still have submodules for my repository. Just that I cannot find the .gitmodulesfile anywhere.

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

回答by kirelagin

  1. Make sure that there are no submodulesections in .git/config. If there are, remove them.
  2. Do git rm --cached <path_to_submodule>.
  1. 确保没有submodule节在.git/config。如果有,请删除它们。
  2. git rm --cached <path_to_submodule>

回答by AndreiMotinga

In addition to the above I also had to remove .gitmodules.

除了上述我还不得不删除.gitmodules.

回答by TianaR

just got over the same issue yesterday, after having deleted by hand the entry in .gitmodules(e.g. nano .gitmodules), I had to go with

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

git rm --cached <pathtomodule> 

which returned a message

返回了一条消息

rm '<pathtomodule>'

then I needed a

然后我需要一个

git commit -m "delete cached modules"

and validated the submodule deletion.

并验证子模块删除。

回答by tivnet

Adding to the answer by @kirelagin :

添加@kirelagin 的答案:

Not always you need to do git rm. Sometimes, it's merely a typo in your .gitmodules. Here I made a few snapshots and commentaries on how SourceTree Git might lose track of submodules.

并非总是您需要这样做git rm。有时,这只是您的.gitmodules. 在这里,我制作了一些关于SourceTree Git 如何失去对子模块的跟踪的快照和评论。