0

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

jub0bs
  • 60,866
  • 25
  • 183
  • 186
Princy
  • 613
  • 1
  • 6
  • 11
  • Please specify what you mean by "4-digit tag". In your example, is `v1.2.0.12` the latest "4-digit tag"? – jub0bs Nov 17 '14 at 17:47
  • Correct. The pattern matching X.X.X.X – Princy Nov 17 '14 at 17:48
  • Did you get that command from somewhere else on the site? From [there](http://stackoverflow.com/a/7979255/2541573)), perhaps? If so, it would be good to link to it. – jub0bs Nov 17 '14 at 18:00

1 Answers1

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.

jub0bs
  • 60,866
  • 25
  • 183
  • 186