Skip to content

Commit 5b2b107

Browse files
committed
Submodules: mention git submodule sync
This command is required if the submodule URL recorded in the superproject changes, in order to synchronize this URL from .gitmodules to the local configuration files .git/config and .git/modules/<name>/config. Add a note concerning this command at the end of the 'Pulling Upstream Changes from the Project Remote' section.
1 parent aabe621 commit 5b2b107

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

book/07-git-tools/sections/submodules.asc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,19 @@ This will make Git run `git submodule update` right after the pull, putting the
437437
Moreover, if you want to make Git always pull with `--recurse-submodules`, you can set the configuration option `submodule.recurse` to true (this works for `git pull` since Git 2.15).
438438
This option will make Git use the `--recurse-submodules` flag for all commands that support it (except `clone`).
439439

440+
There is a special situation that can happen when pulling superproject updates : maybe the upstream repository changes the URL of the submodule in the `.gitmodules` file in one of the commits you pull.
441+
This can happen for example if the submodule project changes its hosting platform.
442+
In that case, it is possible for `git pull --recurse-submodules`, or `git submodule update`, to fail if the superproject references a submodule commit that is not found in the submodule remote locally configured in your repository.
443+
In order to remedy this situation, the `git submodule sync` command is required:
444+
445+
[source,console]
446+
----
447+
# copy the new URL to your local config
448+
$ git submodule sync --recursive
449+
# update the submodule from the new URL
450+
$ git submodule update --init --recursive
451+
----
452+
440453
===== Working on a Submodule
441454

442455
It's quite likely that if you're using submodules, you're doing so because you really want to work on the code in the submodule at the same time as you're working on the code in the main project (or across several submodules).

0 commit comments

Comments
 (0)