Reputation: 1857
I've cloned a repository that has submodules in it and the submodules have all been git-inited and git-updated. After a changed has been pushed into one or more submodules (by another machine) I run this command:
git submodule foreach git pull origin master
to get the latest locally - but when I enter into my submodules and do a git status
I get a "Not currently on any branch" message. I then have to do a combination of git checkout
and git pull
to get back on track to the submodule's master branch.
If my goal is to do a "get latest from the main branch" across all of my submodules, what is the correct foreach command?
Edit for Example:
Consider this:
Now, what I'm asking for is the syntax to bring Z up to date and get the latest change in B - in such a way that it can scale for multiple submodules.
Upvotes: 1
Views: 994
Reputation: 21343
If I understood you correctly you want to get all changes on all submodules and merge them in. If so git submodule update --merge
should do the trick. Not sure why you even tried to use foreach there.
Upvotes: 1