0

Given a git tag (ex. v.0.1.0) I would like a bash command that will give me the previous chronological tag (ex. v.0.0.5). Here I'm using semver for version control and you can see that I can't just decrement the numbers. I need the previous last tag that was given to the repo. Thoughts?

I've tried git describe --tags and its giving me the last tag kindof. But nothing this specific.

1
  • Is there a problem with the git describe --tags output? Is it incorrect? Is it information than you need? Something else? Commented Jan 26, 2015 at 19:48

1 Answer 1

2

There are several solutions out there for listing your tags in chronological order. The one that I often use is:

git for-each-ref --sort=authordate --format '%(refname) %(authordate)' refs/tags 

This works fine if all your tags are "lightweight" tags. If all your tags are annotated tags, use taggerdate instead of authordate. With your tags listed in chronological order, it should be easy to find the tag chronologically prior to any other given tag.

See also:

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.