我试图更新我的子模块,使它们使用更近期的提交。
当我们使用子模块时,它们应该保持在一个分离的 HEAD 状态。这没问题。
$ 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
,但是没有任何区别。我还阅读了这两篇关于该主题的文章,但我的问题并没有被解决:
git submodule update --remote
有什么方面无法帮助的吗? - phdotherlibrary
文件夹中的任何内容仍然不是最新的代码。 - 101010git submodule update --remote
must be run from the superproject:cd myproject
but notcd otherlibrary
- phdgit submodule update --remote otherlibrary && git add otherlibrary && git commit -m "Update otherlibrary"
. Orcd otherlibrary && git checkout master && git pull && cd .. && git add otherlibrary && git commit -m "Update otherlibrary"
- phd