Show which git tag you are on?
git查看当前代码是在那个tag?
reference: https://stackoverflow.com/questions/3404936/show-which-git-tag-you-are-on
-----------------------------------------------------
Edit: Jakub Narębski has more git-fu. The following much simpler command works perfectly:
git describe --tags
(Or without the --tags
if you have checked out an annotated tag. My tag is lightweight, so I need the --tags.)
original answer follows:
git describe --exact-match --tags $(git log -n1 --pretty='%h')
Someone with more git-fu may have a more elegant solution...
This leverages the fact that git-log
reports the log starting from what you've checked out. %h
prints the abbreviated hash. Then git describe --exact-match --tags
finds the tag (lightweight or annotated) that exactly matches that commit.
The $()
syntax above assumes you're using bash or similar.
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步