Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "--remote" actually do in "git submodule update --remote"?

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

or

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?

like image 284
maze Avatar asked Jan 04 '23 04:01

maze


1 Answers

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 submodule.foo.branch = bar in .gitmodule, thenbar and origin/bar are used.

like image 139
ElpieKay Avatar answered Jan 05 '23 18:01

ElpieKay