Reputation: 14250
I have a repo with a submodule in a /modules directory.
I now want to force push the whole repo content incl. the contents of /modules to another repo (used for deployment).
However, it seems that the contents of the target repo do not get updated when I have changes in the submodule. This is what I run to push the contents:
- git pull
- git submodule update --init --recursive
- git push -f --recurse-submodules=on-demand https://example.com/deployment.git master
Upvotes: 5
Views: 3895
Reputation: 489858
Submodules are just Git repositories.
You can use git submodule foreach
to run arbitrary commands in each submodule. Some Git commands have --recurse-submodules
options to run specific (appropriate) commands in each submodule. The --recurse-submodules=on-demand
option to git push
is such a thing: it will enter submodules that have been modified and run another git push
command within those other Git repositories.
The submodule's git push
seems1 to have the form:
git push <remote> <commit>:<branch>
which requires that the submodule repository have some branch name checked out. This name apparently has to match the branch name in the superproject. It then appears as the :<branch>
part of the git push
.
If the submodule push does not happen for any reason, the superproject push fails and does not happen (is aborted).
We cannot tell from your question (because you did not include any output from any of these commands) whether the push completed or failed, and if it failed, why it might have failed. Note, however, that even if the submodule push itself completes, this is like any other git push
: there's no guarantee that the target of the push does anything at all with any new commits received. That is up to the target Git repository.
You say:
However, it seems that the contents of the target repo do not get updated when I have changes in the submodule. This is what I run to push the contents:
There are at least two targets here: the submodule repository's remote, and your superproject's remote. Which one(s) did not get updated? What error(s) did you get if any? What deployment policies are in effect at the submodule's target and at the superproject's target, if any?
1I did some simple tests and found some error cases, e.g., when the submodule has a different branch name checked out.
Upvotes: 3