What Does "--remote" Actually Do In "git Submodule Update --remote"?

- 1 answer

I just do not understand the help page of Git. So what does happen or what is the difference?

Assume I have a Git project A with a submodule B. Submodule B does have a submodule C. After cloning the repository A points to a specific commit of B. And B points to a specific commit of C.

If I am inside A I go to B by

cd B

Now I type

git submodule update --remote


git submodule update

What is the difference? Assuming that the remote server does have changes in A, B and C.

I guess that using "git submodule update --remote" keeps the reference to the specific version of C. Does using it without --remote update to the latest version of C?



Suppose B is the only submodule of A.

cd A
git ls-tree -r HEAD | grep commit

The output is something like

160000 commit 0814c6ba8f45829f04709c56118868d2483444c2 foo

foo is the submodule folder and 0814c6ba8f45829f04709c56118868d2483444c2 is its revision tracked by A's current commit.

git submodule update does something like

cd B
git checkout 0814c6ba8f45829f04709c56118868d2483444c2

git submodule update --remote is like

cd B
git fetch origin master
git checkout origin/master

By default master and origin/master are used. If the branch is specified by = bar in .gitmodule, thenbar and origin/bar are used.