How to git tag all submodules?

偶尔善良 提交于 2019-12-09 10:57:12

问题


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:

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.


回答1:


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.



来源:https://stackoverflow.com/questions/44318543/how-to-git-tag-all-submodules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!