我有一个项目,在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 clone --recurse-submodules https://github.com/chaconinc/MainProject

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

它的作用是:

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

就是这样

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

其他回答

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

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

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

它的作用是:

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

就是这样

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

文件夹映射可以在.git/modules文件夹中找到(每个文件夹都有参考其工作树的配置文件),因此确保这些文件夹对应于.gitmodules和.git/config中的配置。

因此.gitmodules有正确的路径:

[submodule "<path>"]
  path = <path>
  url = git@github.com:foo/bar.git

在[core]部分的.git/modules/<path>/config中,你有你的<path>的正确路径,例如。

[core]
  repositoryformatversion = 0
  filemode = true
  bare = false
  logallrefupdates = true
  worktree = ../../../<path>

如果在.git/modules中没有正确的文件夹,那么你必须去你的子模块目录并尝试git reset HEAD——hard或git checkout master -f。如果这没有帮助,你可能想删除所有对损坏子模块的引用,然后重新添加它,然后参见:重命名git子模块。

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

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

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

在查看了我的.gitmodules之后,我发现我确实在不应该出现的地方出现了一个大写字母。所以请记住,.gitmodules目录是区分大小写的

场景:将子模块从目录dirA-xxx更改为另一个目录dirB-xxx

move the dirA-xxx to dirB-xxx modify entry in .gitmodules to use dirB-xxx modify entry in .git/config to use dirB-xxx modify .git/modules/dirA-xxx/config to reflect the correct directory modify dirA-xxx/.git to reflect the correct directory run git submodule status if return error: No submodule mapping found in .gitmodules for path dirA-xxx. This is due to dirA-xxx is not existing, yet it is still tracked by git. Update the git index by: git rm --cached dirA-xxx Try with git submodule foreach git pull. I didn't go through the actual study of git submodule structure, so above steps may break something. Nonetheless going through above steps, things look good at the moment. If you have any insight or proper steps to get thing done, do share it here. :)