Lukasz Lukasz - 1 month ago 6
Git Question

How to get last Git tag matching regex criteria

I need Git command to get/find last tag starting with 'v' to get last versioning commit (I am using tags with v letter at the beginning to tag next application version (example: v0.9.1beta).

Is there any way to do it?

Answer

I'm using the following command for this:

git describe --match "v[0-9]*" --abbrev=4 HEAD

It will also modify the version if you did something with the source tree since your last versioned tag.

Please note that this is not a regex but a glob but works for the provided example.

Comments