Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to git tag all submodules?

I would like to tag all of the submodules of my project. I tried to do that with:

git submodule foreach git tag tagName

... but it appears to just return with no errors, having done nothing.

Edit: Here are the results of my attempt:

enter image description here

Can someone tell me how to properly tag all submodules?

Note: this a very similar question to this post, but the answer for that one suggested to rely on the submodule refs in the super-project. I, however, would actually like a tag in the submodule's repo.

like image 984
Eric Avatar asked Jun 01 '17 23:06

Eric


Video Answer


1 Answers

First, make sure your submodule folder have a content:

git submodule update --init --recursive

Then, simply do:

 git submodule foreach git tag -l

You should see, for each submdule, tagName.
Meaning your previous command did indeed tag those submodules.

I would recommend to make an annotated tag though, not a lightweight one:

git submodule foreach git tag -m "tagName" tagName

That means you can push that tag from each submodule.

If you just tag at the parent repo level, that will include the submodule gitlink, that is their SHA1. That could be enough in your case.

like image 146
VonC Avatar answered Sep 30 '22 05:09

VonC