What is the difference between running
git submodule update --remote
vs
cd <submodule directoy>
git pull
Assuming that the submodule was previously set to track some branch:
git submodule add -b master [URL to Git repo]
The difference is:
git pull
will only update your submodule branch, but it can be any branch that you could have checked out yourself in that submodule repo.git submodule update --remote
will only update the branch registered in the .gitmodule
, and by default, you will end up with a detached HEAD, unless --rebase
or --merge
is specified or the key submodule.$name.update
is set to rebase
, merge
or none
.In both cases, you still have to go back to the parent repo, add and commit the new submodule SHA1 reference.
That is because in both instances, the SHA1 of the submodule changes, which means the gitlink (special entry in the index of the parent repo, named after to root folder of the submodule) must be added and committed.
A git submodule update --init --remote
is like:
git submodule init
: to initialize (checkout) the submodules recorded in the indexgit submodule update --remote
: to pull from the registered branch (or master by default), once the submodule has been initialized (checked out).