4

I manage a repository with several submodules. For a while now I've been using

$ git submodule foreach git pull origin master

to pull in the latest changes for all of these guys. However, recently I learned about

$ git pull --recurse-submodules

and gave it a try but it seems that changes are only fetched so you need to

$ git submodule update --recursive

in order to actually checkout the changes. However, this last seems to do nothing in my repository despite submodules clearly pulling changes. I also noticed that my submodules are checked out to some commit instead of master or whatever branch.

  1. Am I doing something improperly?
  2. Or is this an artifact of the foreach way I used to do things?
  3. How can I fix things up so that pull --recurse-submodules and submodule update --recursive work as expected?

1 Answer 1

1

git submodule update --recursive is updating the submodules to match the commit in the parent repo. So you need to commit a change to the parent repo for that command to do anything.

With this setup:

/proj/.git
/proj/module/.git

You make changes in "module", commit, and push them. In "proj", you commit module (it just shows the submodule commit hash changing).

Now when you pull and submodule update, it will update "module" to use the new commit.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .