In Git, how do I pull from a repository and get all the submodule changesets that are commited in that repository's submodule child repo's?
I'm trying to use git submodules
with a topology like:
parent_repo
`-- child_repo
We're maintaining a trunk copy that we all push and pull from. ( I know a star topology is not necessary. I realize you can pull from each other without reflecting through a central repository.)
trunk_child_repo <--+
|
trunk_parent_repo |
`-- child_repo -----+ # child_repo will pull from trunk_child_repo by default
Now we have multiple copies of trunk_parent_repo
with fully-populated submodules.
trunk_parent_repo
`-- child_repo
ross_parent_repo
`-- child_repo
bob_parent_repo
`-- child_repo
joe_parent_repo
`-- child_repo
I'm in the ross_parent_repo
and I want to pull from bob_parent_repo
and get all the edits that bob has done to the files in bob_parent_repo
as well as the edits he's committe开发者_开发知识库d to his submodule bob_parent_repo/child_repo
.
Unfortunately, when I do a git pull --recurse-submodules bob_parent_repo
, it pulls from bob_parent_repo
into ross_parent_repo
, but trunk_child_repo
into ross_parent_repo/child_repo
.
Is it possible to have a nice, easy command to pull all the changesets that Bob has done in bob_parent_repo
as well as all the changesets that he has done in all of his submodules? Will I have to script it up and iterate through the submodules in the .gitmodules
file?
No need to open up .gitmodules
; you can use git submodule foreach
.
git pull $BOBS_PARENT_REPO
git submodule foreach 'git pull $BOBS_PARENT_REPO/$path/.git'
(This won't work for any submodules-of-submodules, though.)
精彩评论