git config push.recurseSubmodules check
Or you can make it push automatically by replacing "check" with "on-demand".You may also find it helpful to make various commands automatically apply to submodules with:
git config submodule.recurse trueI got excited about the submodule.recurse=true one, but at least for "git status" it did not descend into the submodule the same way that "git submodule foreach git status" does
[1] or rather ../.git/modules/"$submodulename"/hooks/pre-commit, depending on how the submodule was added
> Or you could put a script at .git/hooks/pre-push.sample in the parent repo (untested) that verifies if all commits in submodules are in the respective upstreams
(a) those scripts are most certainly not called .sample (b) it was fast enough to set up a local test case and (as expected) each repo (outer and "inner" submodule) carry their own git hook setups and `echo "exit 1" > .git/hooks/pre-commit` does stop top level commits but does nothing for the inner repos
Yes, I carelessly copy-pasted the path.
And yes, as I said it would probably be a good idea to have a feature like that in the core. -- Ah, I see the other reply, so it's done. I generally recommend asking such questions on #git on IRC, someone will know the answer if a feature already exists.
I haven't experienced that scenario before but it seems like there'd be an obvious git error?
git clone --recursive some/repo.git
cd repo/subrepo
sed -i"" s/hello/goodbye/ README.md
git commit -am 'lololo'
cd ..
git commit -am'subrepo with *local* sha reference'
git status # everything is clean!
now that I know that can happen, running `git submodule foreach git status` will surface the "your branch is ahead of" magic text that indicates what has gone on, but it would be tons better if the system understood what was happening and didn't allow such a bad outcome