Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to prevent unpushed submodules in git

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

like image 335
Zernel Avatar asked Sep 19 '14 02:09

Zernel


1 Answers

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.

like image 87
VonC Avatar answered Oct 05 '22 19:10

VonC