git子模块引用不存在的SHA

时间:2013-09-19 01:34:08

标签: git git-submodules

我从rcbops中获取了以下文件:

https://github.com/rcbops/chef-cookbooks

我在内部移动了它们,复制了所有的食谱。

然后我编辑了.gitmodules文件以指向我的本地回购。

在我内部上传repos的时间和我测试代码的时间之间,外部存储库已更新。 (特别是Rabbitmq)。

运行我的命令后下载子模块。我收到以下错误:

fatal: reference is not a tree: c04c57b549c2b79f2df5922aad3a27769234bf5c
Unable to checkout 'c04c57b549c2b79f2df5922aad3a27769234bf5c' in submodule path 'cookbooks/rabbitmq'

从它的外观来看,它看起来像是引用了一个外部SHA,但在我的本地存储库中找到了那个SHA。

我该如何解决这个问题?

2 个答案:

答案 0 :(得分:1)

更改.gitmodule可能还不够。

也可能需要git submodule update

检查父回购的内容:

  • .git/config查看子模块“chef-cookbooks”网址是否已更改
  • cd .git/modules/chef-cookbooks:查看git remote -v是否为空或指向您自己的子模块仓库。

答案 1 :(得分:0)

git submodule update --remote -f [module name]

这会将您的子模块更新到头部

相关问题