Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git submodule specify version

Tags:

git

I have git submodule. I have .gitmodules file.

[submodule "templates-ui/src/main/webapp/js/app/ui"]
    path = templates-ui/src/main/webapp/js/app/ui
    url = [email protected]:xxx/ui-core.git

I did init and update.

But how to specify the version of the submodule? For example I may have version of of ui-core as 2.3.2 or 2.3.3.

like image 599
lapots Avatar asked Feb 11 '23 02:02

lapots


1 Answers

git tracks submodules as ordinary objects. this means, that once you added the submodule, the exact state (e.g. revision) of the submodule is stored in the parent module as well.

so do:

cd submodule
git checkout v2.3.2
cd -
git commit . -m "use submodule v2.3.2"

as side-effect of the way githandles submodules is, that you cannot have a "live" submodule¹ (where you always track the HEAD of a master branch) - a submodule is really always in a detached state.

¹ well you can; nobody keeps you from tracking master/HEAD in the submodule by manually pulling within the submodule; but the parent module will always reference a specific commitish.

like image 157
umläute Avatar answered Feb 12 '23 16:02

umläute