我知道这个问题已经被打死了。但是我仍然没有清楚地理解为什么我的子模块试图引用我的超级项目中的提交。我有一个项目,其中包含许多子模块,其中一些子模块引用了我想要贡献的github存储库。更新模块后,我拉出模块的更改:
[ashinn@puppet1 puppet]$ cd modules/ganglia [ashinn@puppet1 ganglia]$ git branch * (no branch) master [ashinn@puppet1 ganglia]$ git pull origin master remote: Counting objects: 8, done. remote: Compressing objects: 100% (4/4), done. remote: Total 6 (delta 4), reused 4 (delta 2) Unpacking objects: 100% (6/6), done. From https://github.com/andyshinn/puppet-ganglia * branch master -> FETCH_HEAD Merge made by recursive. README | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
现在我想更新超级项目中对模块的引用:
[ashinn@puppet1 ganglia]$ cd ../.. [ashinn@puppet1 puppet]$ git add modules/ganglia [ashinn@puppet1 puppet]$ git commit -m 'updated ganglia module' [ganglia c172591] updated ganglia module 1 files changed, 1 insertions(+), 1 deletions(-)
我目前正在处理神经节分支,所以我把它推到我的原点(这是2个不同的URL):
[ashinn@puppet1 puppet]$ git push origin ganglia Counting objects: 8, done. Delta compression using up to 2 threads. Compressing objects: 100% (6/6), done. Writing objects: 100% (6/6), 616 bytes, done. Total 6 (delta 4), reused 0 (delta 0) To git@github.com:andyshinn/puppet.git 1876698..c172591 ganglia -> ganglia Counting objects: 5, done. Delta compression using up to 2 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 323 bytes, done. Total 3 (delta 2), reused 0 (delta 0) remote: From /var/lib/puppet/repo remote: dcd1fcc..c172591 ganglia -> origin/ganglia remote: From https://github.com/andyshinn/puppet-ganglia remote: a0c4e21..975c92f master -> origin/master remote: fatal: reference is not a tree: c5defdeae006c7b87058cc5c79aef60087b63a6b remote: Unable to checkout 'c5defdeae006c7b87058cc5c79aef60087b63a6b' in submodule path 'modules/ganglia' remote: Updating existing environment ganglia To puppet@puppet.mydomain.com:repo dcd1fcc..c172591 ganglia -> ganglia
遥控器有一个接收后脚本,用于检出不同文件夹中的分支,并为每个文件夹运行git submodule update --init
。如果我手动连接到原始仓库,我可以验证问题:
-bash-4.1$ git pull Already up-to-date. -bash-4.1$ git submodule update --init fatal: reference is not a tree: c5defdeae006c7b87058cc5c79aef60087b63a6b Unable to checkout 'c5defdeae006c7b87058cc5c79aef60087b63a6b' in submodule path 'modules/ganglia'
我在这里做错了什么?
答案 0 :(得分:0)
当你拉扯时你不在分支上。 HEAD必须指向您想要的位置。更新子模块的正确方法是
git checkout master
git push origin master
现在,当前提交指向您希望的位置。执行此操作后,您可以在超级项目中添加子模块更改,添加,提交和推送。
另一种方法是制作子模块中当前HEAD所在位置的分支或标记,然后推动它:
git tag interesting HEAD
git push origin interesting
cd ../..
git add submodule/path
git commit -m "updated my submodule"
git push