git tag from commit

C++
$ git tag -l -n2$ git tag <tag_name> HEAD   (for the last commit)$ git rev-list -n 1 $TAG
Source

Also in C++: