Skip to content

Commit

Permalink
Merge pull request #1368 from phil-blain/submodule-sync
Browse files Browse the repository at this point in the history
Submodules: mention `git submodule sync`
  • Loading branch information
ben authored Jan 30, 2020
2 parents aabe621 + 84299a2 commit 0c09fcd
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions book/07-git-tools/sections/submodules.asc
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,19 @@ This will make Git run `git submodule update` right after the pull, putting the
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).
This option will make Git use the `--recurse-submodules` flag for all commands that support it (except `clone`).

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.
This can happen for example if the submodule project changes its hosting platform.
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.
In order to remedy this situation, the `git submodule sync` command is required:

[source,console]
----
# copy the new URL to your local config
$ git submodule sync --recursive
# update the submodule from the new URL
$ git submodule update --init --recursive
----

===== Working on a Submodule

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).
Expand Down

0 comments on commit 0c09fcd

Please sign in to comment.