我有一个项目,在lib/three20有一个子模块

我的.gitmodule文件是这样的:

[submodule "lib/three20"]
    path = lib/three20
    url = git://github.com/facebook/three20.git

我克隆了这个在过去没有错误,(git子模块init紧随git子模块更新),它已经工作了一段时间。

我试图克隆这个到一个新的机器,现在我在git子模块init上得到这个错误:

No submodule mapping found in .gitmodules for path 'Classes/Support/Three20'

这个路径只是Xcode中的一个空文件夹,我用它来存放来自另一个目录的项目。它不是.gitmodules文件的一部分,所以我不知道它从哪里得到这个路径。

什么好主意吗?


当前回答

没有找到子模块路径'path/to/submodule'的url 在.gitmodules中没有找到路径'path/to/submodule'的子模块映射

当我从根目录文件夹“cd”到。/resources/css/style.css时,这些错误就开始了。

我使用git init从style.css,认识到我的错误后,我已经添加 Git添加remote origin <url>。

所以,仍然在git bash中的style.css文件中,我使用git删除远程原点。

当我检查git remote时,远程链接已被删除。

Ultimately, after doing git init for the root directory, adding it to remote, the resources/css path was providing the submodule error/fatal errors listed up top. So, from the root directory, in git bash, I typed git rm --cached resources/css, deleted the css directory (saved the code), pushed the changes, and added a css directory and styles.css file within it in a different branch (optional) to see how the outcome would be after pushing changes again and checking the deployment on github pages. It worked! I know deleting directories isn't always ideal, especially in large projects, but just wanted to share one more way to fix this issue!

ps相当新的stackoverflow,所以我为冗长的文本道歉。 # 2022的答案

其他回答

遵循rajibchowdhury的回答(被点了),使用git rm命令,建议删除索引中指示子模块的特殊条目(特殊模式为160000的“文件夹”)。

如果这个特殊的入口路径没有在.gitmodule中被引用(就像原始问题中的'Classes/Support/Three20'),那么你需要删除它,以避免“在.gitmodules for path中找不到子模块映射”错误消息。

你可以检查索引中所有引用子模块的条目:

git ls-files --stage | grep 160000

之前的回答(2010年11月)

有可能你没有正确地声明你的初始子模块(即没有任何结尾的'/',正如我以前的回答中所描述的,即使你的.gitmodule有看起来不错的路径)。

这个帖子提到:

当从一个新的克隆运行'git submodule init'时,你会得到相同的错误吗? 如果是这样,你就有问题了。 如果没有子模块,请删除.gitmodules,以及中对子模块的任何引用 .git/config,并确保Pikimal目录中没有.git目录。 如果这解决了问题,签入并在您的巡航工作副本上做同样的事情。

显然,不要删除你的主.gitmodules文件,但要照顾你工作树中其他额外的.gitmodules文件。


仍然在“不正确的子模块初始化”的主题中,Jefromi提到了实际上是gitlinks的子模块。

参见如何跟踪未跟踪的内容?以便将这样的目录转换为真正的子模块。

只要git rm subdir就可以了。这将删除作为索引的子目录。

通常,git会在项目的根目录(.git/)中创建一个隐藏目录。

当你在CMS上工作时,你可能会安装带有.git/目录的模块/插件,其中包含特定模块/插件的git元数据

最快的解决方案是找到所有的.git目录,只保留根git元数据目录。如果这样做,git将不会将这些模块视为项目子模块。

没有找到子模块路径'path/to/submodule'的url 在.gitmodules中没有找到路径'path/to/submodule'的子模块映射

当我从根目录文件夹“cd”到。/resources/css/style.css时,这些错误就开始了。

我使用git init从style.css,认识到我的错误后,我已经添加 Git添加remote origin <url>。

所以,仍然在git bash中的style.css文件中,我使用git删除远程原点。

当我检查git remote时,远程链接已被删除。

Ultimately, after doing git init for the root directory, adding it to remote, the resources/css path was providing the submodule error/fatal errors listed up top. So, from the root directory, in git bash, I typed git rm --cached resources/css, deleted the css directory (saved the code), pushed the changes, and added a css directory and styles.css file within it in a different branch (optional) to see how the outcome would be after pushing changes again and checking the deployment on github pages. It worked! I know deleting directories isn't always ideal, especially in large projects, but just wanted to share one more way to fix this issue!

ps相当新的stackoverflow,所以我为冗长的文本道歉。 # 2022的答案

我解决了删除回购和运行这个命令

git clone --recurse-submodules https://github.com/chaconinc/MainProject

在那之后,它对我来说工作得很好,因为这里没有一个选项是有用的

它的作用是:

克隆主回购 在克隆完成后立即初始化子模块

就是这样

你可以在下面这个链接找到更多信息