Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get git tag of checked out revision?

Tags:

git

tags

I'm doing

$ git tag

current
tag_example_to_test_task

$ git checkout tag_example_to_test_task

...

HEAD is now at 75fdde3... commit comment text example

 $ git name-rev --name-only --tags HEAD

current

$ git describe --exact-match --tags

current

I need to end execution sequence with some command like this:

$ git "some command here"

tag_example_to_test_task

How to do that? How to get tag name of current checked out tag?

like image 483
Vyacheslav Avatar asked Nov 12 '22 08:11

Vyacheslav


1 Answers

I think

git log -n 1 --pretty=format:'%d'

should do the trick.

However, it'll show you names of all branches and tags your current revision has. I don't think it's possible to get just the single tag that have been used to check out the revision.

like image 152
shakurov Avatar answered Nov 15 '22 06:11

shakurov