I am trying to update my submodules so that they use a more recent commit.
When we use submodules, they are supposed to remain in a detached head state. That's fine.
$ cd myproject
$ cd otherlibrary
$ git status .
HEAD detached from 091eccc
nothing to commit, working tree clean
I did some work in otherlibrary
and now I'd like to update myproject
so that it will use these new commits in otherlibrary
. That means, I need to 'update the submodule' somehow.
This doesn't work: (see? it's still has the same commit number)
$ cd myproject
$ cd otherlibrary
$ git submodule update --remote
$ git status .
HEAD detached from 091eccc
nothing to commit, working tree clean
For completeness, I also tried it like this git submodule update --rebase --remote
and like this git submodule update --merge --remote
and that doesn't make any difference.
I also read these two SO articles that talk about the subject, but my problem isn't solved by this:
As phd noted in a comment , to use git submodule update
, you must be in the superproject .
(All git submodule update --remote
does is cd
into the submodule, run a git fetch
, and then run a git checkout
, so if you don't want to pop back up to the superproject for some reason, you can run the git fetch
and git checkout
yourself. If you do this, you can poke around in the fetch results and carefully choose the specific commit you'd like, rather than just taking the one identified by origin/master
or whatever. Of course, if the one you'd like is whichever one is identified by origin/master
, the git submodule update --remote
is convenient.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.