git submodule update
does several things under the hood. From git help submodule
:
Update the registered submodules to match what the superproject
expects by cloning missing submodules, fetching missing commits in
submodules and updating the working tree of the submodules.
So running git submodule update --remote
is roughly equivalent to (inside the submodule):
$ git fetch origin # update remote-tracking branches
$ git checkout origin/HEAD # update working tree
origin/HEAD
is a remote-tracking branch that follows the branch from the remote repository (it is normally hidden, but you can see it with git branch --remotes
). Note that the git fetch
incurs network activity, but the git checkout
happens entirely locally.
--no-fetch
skips the first step, but will still update your submodule working tree to the remote tracking branch.
I don't think there is a common situation when you would prefer --no-fetch
, but it would probably be most useful in situations of limited connectivity. For example, before you go on an airplane, you can git fetch --recurse-submodules
. Then during the flight you can use git submodule update --remote --no-fetch
(update to submodule remote-tracking branch) or git submodule update --no-fetch
(update to commit recorded in superproject) without accessing the network. However this would not have the "current tracking branch state," since your remote-tracking branch will only be as recent as your last fetch.