Skip to content

Commit 0c09fcd

Browse files
authored
Merge pull request #1368 from phil-blain/submodule-sync
Submodules: mention `git submodule sync`
2 parents aabe621 + 84299a2 commit 0c09fcd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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

+13
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: it could be that the upstream repository has changed 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)