How can I get the latest tag of the form vX.X.X.X?

爷,独闯天下 提交于 2019-12-13 04:42:52

问题


Here is a list of tags I get when I do git describe --tags:

v1.1.8
v1.1.9
v1.2.0
v1.2.0.1
v1.2.0.10
v1.2.0.11
v1.2.0.12

If I do

git describe --tags `git rev-list --tags --max-count=1`

I may get tag with either 3 digit or 4 digit. I only want to pick up the latest 4 digit tag. How can I always get the latest 4 digit git tag?

What I mean by the 4 digit tag is anything with vX.X.X.X


回答1:


Edit: You write

I only want to pick up the latest 4-digit tag.

(my emphasis)

However, your question really only makes sense for annotated tags, which, contrary to lightweight tags, do have a date associated to them. In that respect, a lightweight tag is not that much different from a branch reference.

  • To list all tags (either annotated or lightweight) in your repository that match the pattern vX.X.X.X (where X stands for one or more digits), run

    git tag | grep -E "v([0-9]+\.){3}[0-9]+"
    

If you want something else, please clarify your question.



来源:https://stackoverflow.com/questions/26977922/how-can-i-get-the-latest-tag-of-the-form-vx-x-x-x

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