Git submodule update vs git submodule sync

The documentation gitdoes not fully understand what the difference between git submodule updateand a is git submodule sync. I also did not find any help on the Internet. Can someone help me, what's the difference here?

   update
       Update the registered submodules to match what the superproject expects
       by cloning missing submodules and updating the working tree of the
       submodules. The "updating" can be done in several ways depending on
       command line options and the value of submodule.<name>.update
       configuration variable.

-

   sync
       Synchronizes submodules' remote URL configuration setting to the value
       specified in .gitmodules. It will only affect those submodules which
       already have a URL entry in .git/config (that is the case when they are
       initialized or freshly added). This is useful when submodule URLs
       change upstream and you need to update your local repositories
       accordingly.

For reference, I am using git client version 2.11.0

+4
source share
2 answers

updatebasically executes git pullin each submodule (except without a branch, since the main repo sets the commit directly).

Difficult << 22>. Imagine that you are cloning a project with submodules, and then the upstream project changes one of the submodules to a different URL.

- URL-, git . git submodule sync, .

, , , URL- , ... URL-, , .

+5

git submodule update . "git fetch" "git checkout" .

git submodule sync , URL- . .git/config .gitmodules.

+5

Source: https://habr.com/ru/post/1683699/


All Articles