我有一个项目,在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文件的一部分,所以我不知道它从哪里得到这个路径。

什么好主意吗?


当前回答

我刚刚在尝试“git子模块初始化”后遇到了这个错误,在我的回购的新签出。原来我最初用错误的大小写指定了模块子文件夹。因为我用的是区分大小写的Mac文件系统(hurr),所以它失败了。例如:

git submodule add git@github.com:user/project.git MyApp/Resources/Project
Cloning into 'MyApp/Resources/Project'

成功,但问题是在磁盘上的路径是

Myapp/Resources/Project

我不明白的是,为什么git将模块初始化到错误的文件夹(忽略我命令中的不正确情况),但随后使用后续命令正确操作(失败)。

其他回答

当我使用SourceTree来做这些事情时,它会吐出这条消息。 我遇到的信息是:

git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree submodule update --init --recursive
No submodule mapping found in .gitmodules for path 'SampleProject/SampleProject'
Completed with errors, see above

我的场景是我错用了项目目录,包含。git文件夹。 SourceTree认为这个文件夹是git的子模块,但实际上不是。

我的解决方案是使用命令行删除它。

$ git rm -r SampleProject --cached
$ git commit -m "clean up folders"

清除git中的垃圾并保持清洁。

我刚刚在尝试“git子模块初始化”后遇到了这个错误,在我的回购的新签出。原来我最初用错误的大小写指定了模块子文件夹。因为我用的是区分大小写的Mac文件系统(hurr),所以它失败了。例如:

git submodule add git@github.com:user/project.git MyApp/Resources/Project
Cloning into 'MyApp/Resources/Project'

成功,但问题是在磁盘上的路径是

Myapp/Resources/Project

我不明白的是,为什么git将模块初始化到错误的文件夹(忽略我命令中的不正确情况),但随后使用后续命令正确操作(失败)。

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

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

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

它的作用是:

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

就是这样

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

有个问题。有一段时间,我尝试了删除路径的建议,git删除路径,删除.gitmodules,从.git/config中删除条目,重新添加子模块,然后提交并推送更改。这是令人困惑的,因为当我做“git commit -a”时,它看起来没有变化,所以我试着只推删除,然后推读取,使它看起来像一个变化。

After a while I noticed by accident that after removing everything, if I ran "git submodule update --init", it had a message about a specific name that git should no longer have had any reference to: the name of the repository the submodule was linking to, not the path name it was checking it out to. Grepping revealed that this reference was in .git/index. So I ran "git rm --cached repo-name" and then readded the module. When I committed this time, the commit message included a change that it was deleting this unexpected object. After that it works fine.

不知道发生了什么,我猜有人误用了git子模块命令,可能颠倒了参数。甚至可能是我……希望这能帮助到一些人!

在我的例子中,错误可能是由于两个分支上具有不同子模块配置的.gitmodules之间的错误合并。 在听取了这个论坛的建议后,我解决了手动编辑.gitmodules文件的问题,添加缺少的子模块条目非常容易。之后,命令 Git子模块update——init——递归 没有任何问题。