Please note that since git1.7.11 ( [ANNOUNCE] Git 1.7.11.rc1 and the release note , June 2012) mentions:
" git push --recurse-submodules " learned to further study the history of submodules associated with a superproject and push them out.
Perhaps after this patch and the --on-demand parameter:
recurse-submodules=<check|on-demand>::
Make sure that all submodular commits used by draggable revisions are available in the remote tracking branch.
- If
check used, it will be verified that all submodules that have been changed in the versions that need to be clicked are available on the remote computer.
Otherwise, the press will be interrupted and exit with a non-zero status. - If
on-demand , all submodules that changed during permutations will be pressed.
If upon request it was not possible to make all the necessary changes, it will also be interrupted and exit with a non-zero status.
So, you can click all at once (from the parent repo) a:
git push --recurse-submodules=on-demand
This option only works for one level of nesting. Changes to a submodule within another submodule will not be pushed.
With Git 2.7 (January 2016), a simple push of Git will be enough to push the parent repo ... and all its submodules.
See commit d34141c , commit f5c7cd9 (December 03, 2015), commit f5c7cd9 (December 03, 2015) and commit b33a15b (November 17, 2015) Mike Crowe .
(merger of Junio C Hamano - gitster - on commit 5d35d72 , December 21, 2015)
push : add recurseSubmodules configuration option
The command line --recurse-submodules exists for some, but it does not have the equivalent of a configuration file.
Following the style of the corresponding parameter for git fetch , let's push.recurseSubmodules up with push.recurseSubmodules to specify the default value for this parameter. It also requires the addition of --recurse-submodules=no to allow command-line configuration overrides when required.
The easiest way to implement this, apparently, is to do push use the code in submodule-config similar to fetch .
git config doc now includes :
push.recurseSubmodules :
Make sure that all submodular commits used by reissues are available in remote tracking branches.
- If the value is '
check ', then Git will verify that all submodules that have been changed in the revised versions are available at least one submodule removal. If there are no commits, the click will be canceled and will exit with a non-zero status. - If the value is "
on-demand ", then all submodules that have been changed in the revised versions will be pressed. If upon request it was not possible to make all the necessary changes, it will also be interrupted and exit with a non-zero status. - - If the value is '
no ', then the default behavior of ignoring submodules when pressed is preserved.
You can override this configuration at click time by specifying " --recurse-submodules=check|on-demand|no ".
So:
git config push.recurseSubmodules on-demand git push
Git 2.12 (Q1 2017)
git push --dry-run --recurse-submodules=on-demand will work.
See commit 0301c82 , commit 1aa7365 ( Nov 17) 2016) Brandon Williams ( mbrandonw ) .
(merged Junio C Hamano - gitster - in commit 12cf113 , December 16, 2016
push run with --dry-run actually doesn't work (Git Dec 2.11, 2016 and below / before) does a dry job when push is configured to push sub-modules on demand.
Instead, all the submodules that need to be pushed are actually pushed to their remotes, while any updates to the super project are performed as dry runs.
This is a mistake, not the alleged dry run behavior.
Teach push respect the --dry-run option if it is configured to recursively push submodules on demand.
This is done by passing the --dry-run flag to a child process that does push for submodules when a dry run is performed.
And still in Git 2.12, you now have the <-- --recurse-submodules=only "option to pop out the submodules without having to push the top level superproject .
See commit 225e8bf , commit 6c656c3 , commit 14c01bd (December 19, 2016) Brandon Williams ( mbrandonw ) .
( gitster Junio C Hamano - gitster - to commit 792e22e , January 31, 2017)