How to fetch&merge main repository and do the same for all submodules using single command?
I have a repository A which includes submodule B. Submodule B is often updated and changes are not always up to date.
I can update and merge new changes by doing following
cd A/B <-- enter submodule directory
git pull <-- run pull to fetch and !!merge!! submodule changes
What I want to do is to run single command to pull&merge main repository and do the same with all submodules.
cd A <-- Now enter to parent directory
git pull --recurse-submodules <-- Fetch&merge changes on main repository
<-- and pull changes on all submodules
What actually happens is:
- Changes on repository A are fetched and merged => OK
- Changes on submodule repository B are only fetched and not merged => NOK
Current solution is:
cd A
git pull --recurse-submodules
cd B
git merge <-- Now merge fetched changes from submodule remote
or:
cd A
git pull --recurse-submodules
git submodule foreach git merge origin master
Other questions I checked, without luck:
Easy way to pull latest of all git submodules
Run git pull over all subdirectories
Running git --help pull
on git version 2.20.1
I see this message:
BUGS Using --recurse-submodules can only fetch new commits in already checked out submodules right now. When e.g. upstream added a new submodule in the just fetched commits of the superproject the submodule itself can not be fetched, making it impossible to check out that submodule later without having to do a fetch again. This is expected to be fixed in a future Git version.
Is this related to the issue?