'git push recurse-submodules does not work
I just start to use git submodule, but the behavior is not as expected when push submodules recursively.
My git version is 2.26.2.dirty. My repo is simple, where root-project has one submodule 'common_misc'. I do some change in common_misc, add and commit it. Then go to parent directory and add/commit directory common_misc.
After all that, I run in parent directory:
git push --recurse-submodules=on-demand
it will report error:
% git push --recurse-submodules=on-demand
Pushing submodule 'common_misc' Everything up-to-date The following submodule paths contain changes that can not be found on any remote: common_misc
Please try
git push --recurse-submodules=on-demand
or cd to the path and use
git push
to push them to a remote.
fatal: Aborting.
Here is output of git status in parent and sub directories:
% git status .
On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits)
nothing to commit, working tree clean
% cd common_misc
% git status .
On branch dev/test Your branch is ahead of 'origin/dev/test' by 1 commit. (use "git push" to publish your local commits)
nothing to commit, working tree clean
It shows both need be pushed.
I try to push without recursive in both parent and sub directories and that works without any problem.
Solution 1:[1]
I finally found what's going wrong.
The reason is, I am using 'master' branch in root project, but using 'dev/test' branch in submodule. When I run
git push --recurse-submodules=on-demand
in root directory. It will push master branch in both root and submodule directories, although I set dev/test in .gitsubmodules. Having said that, when I cd submodule directory and run 'git push', it will simply push current branch (aka dev/test branch) to the remote repo.
I don't know whether this is a bug or feature. I'd like to see git team to improve it.
I don't see other thread encountering same issue as mine, so, just keep here as a record.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | David Peng |
