我正在尝试更新子模块,以便它们使用更新的提交。
当我们使用子模块时,它们应该保持处于分离的头部状态。很好。
$ cd myproject
$ cd otherlibrary
$ git status .
HEAD detached from 091eccc
nothing to commit, working tree clean
我在otherlibrary
中做了一些工作,现在我想更新myproject
,以便它可以在otherlibrary
中使用这些新的提交。这意味着,我需要以某种方式“更新子模块”。
这不起作用:(看?它仍然具有相同的提交号)
$ cd myproject
$ cd otherlibrary
$ git submodule update --remote
$ git status .
HEAD detached from 091eccc
nothing to commit, working tree clean
为完整起见,我也像这样git submodule update --rebase --remote
和这样git submodule update --merge --remote
那样尝试,但这没有什么区别。
我还阅读了这两篇有关该主题的SO文章,但是我的问题并不能因此解决:
答案 0 :(得分:0)
与phd noted in a comment一样,要使用git submodule update
,您必须在超级项目中。
(git submodule update --remote
所做的全部工作是cd
进入子模块,运行git fetch
,然后运行git checkout
,因此如果您不想弹出来出于某种原因进入超级项目,您可以自己运行git fetch
和git checkout
。如果这样做,则可以在获取结果中四处浏览,并仔细选择所需的特定提交,而不是仅取origin/master
所标识的那个,当然,如果您想要的那个是,则取origin/master
所标识的那个,git submodule update --remote
就是方便。)