How to prevent uncleaned submodules in git
is there some hook script in git that will detect if the source data tree of a submodule is available whenever you click on the main project? Designed to prevent people from hitting a master project that had submodules dissolved.
You can use (git 1.7.7+):
git push --recurse-submodules=on-demand
I present it in a " Git push submodule " and it detects a modification to the submodule to push it first before pushing the main repo.
Please note that there are 2 options:
git push --recurse-submodules=check
git push --recurse-submodules=on-demand
Make sure all submodule commits used by dragged revisions are available on the remote tracking branch.
If using
check
git, it will check that all submodule commits that were changed in the versions to be pushed are available on at least one remote submodule.
If any commits are missing, the push will be canceled and exit with a non-zero status.If used
on-demand
, all sub-modules that have changed in the versions to be clicked will be clicked.
If on-demand failed to push all the required changes, it will also be aborted and exited with a non-zero status.
You can use git submodule foreach
to call any command for each submodule, so to check if your branch is behind / master, do:
git submodule foreach git status
To undo all changes from submodules, run:
git submodule foreach git push
See: man git-submodule
.