lapots
lapots

Reputation: 13395

git submodule specify version

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.

Upvotes: 5

Views: 4441

Answers (1)

umläute
umläute

Reputation: 31284

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.

Upvotes: 10

Related Questions