Reputation: 1547
is there some hook script in git that will detect if the submodule source tree is available whenever you push to the main project? Intend to avoid people pushing a master project that has unpushed submodules
Upvotes: 6
Views: 1895
Reputation: 166899
You can use git submodule foreach
to invoke any command for each submodule, so to check whether your branch is behind origin/master, run:
git submodule foreach git status
To push all your changes from submodules, run:
git submodule foreach git push
See: man git-submodule
.
Upvotes: 0
Reputation: 1329492
You can use (git 1.7.7+):
git push --recurse-submodules=on-demand
I present it in "Git submodule push", and it detects any submodule modification, to push it first, before pushing the main repo.
Note that there are 2 options:
git push --recurse-submodules=check
git push --recurse-submodules=on-demand
Make sure all submodule commits used by the revisions to be pushed are available on a remote tracking branch.
If
check
is used git will verify that all submodule commits that changed in the revisions to be pushed are available on at least one remote of the submodule.
If any commits are missing the push will be aborted and exit with non-zero status.If
on-demand
is used all submodules that changed in the revisions to be pushed will be pushed.
If on-demand was not able to push all necessary revisions it will also be aborted and exit with non-zero status.
Upvotes: 6