I want to find the tag of the last commit if it is present. So far I have found only the option to get the last tag inside all of the tags..
But I want to know if there is a tag on the last commit or no tag?
[edit] @phd pointed out that git tag
has a --points-at
option, which makes for a nicer command :
git tag --points-at HEAD
my initial answer :
You can use the --points-at
option of git for-each-ref
:
git for-each-ref --points-at=HEAD
To display only the tag name, and limit the searched refs to tag :
git for-each-ref --points-at=HEAD --format="%(refname:lstrip=2)" refs/tags
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.