What\'s the simplest way to get the most recent tag in Git?
git tag a HEAD
git tag b HEAD^^
git tag c HEAD^
git tag
output:
I'm not sure why there are no answers to what the question is asking for. i.e. All tags (non-annotated included) and without the suffix:
git describe --tags --abbrev=0
git tag --sort=committerdate | tail -1
git tag -l ac* | tail -n1
Get the last tag with prefix "ac". For example, tag named with ac1.0.0
, or ac1.0.5
. Other tags named 1.0.0
, 1.1.0
will be ignored.
git tag -l [0-9].* | tail -n1
Get the last tag, whose first char is 0-9
. So, those tags with first char a-z
will be ignored.
git tag --help # Help for `git tag`
git tag -l <pattern>
List tags with names that match the given pattern (or all if no pattern is given). Running "git tag" without arguments also lists all tags. The pattern is a shell wildcard (i.e., matched using fnmatch(3)). Multiple patterns may be given; if any of them matches, the tag is shown.
tail -n <number> # display the last part of a file
tail -n1 # Display the last item
With git tag --help
, about the sort
argument. It will use lexicorgraphic order
by default, if tag.sort
property doesn't exist.
Sort order defaults to the value configured for the tag.sort variable if it exists, or lexicographic order otherwise. See git-config(1).
After google, someone said git 2.8.0 support following syntax.
git tag --sort=committerdate
git describe --abbrev=0 --tags
If you don't see latest tag, make sure of fetching origin before running that:
git remote update
You can execute: git describe --tags $(git rev-list --tags --max-count=1)
talked here: How to get latest tag name?
git describe --tags
returns the last tag able to be seen by current branch