获取 git 个没有提交哈希的标签

get git tags without the commit hash

我想要分支的轻量级 git 标签(未注释)但是

git describe --tag 也给了我提交哈希。如何只查询标签

得到:

0.1.2-milestone-343-f20ef9ef2d

想要:

0.1.2-milestone

解决方案:

git describe --tag --abbrev=0

--tags show lightweight tags too
--abbrev=0 removes the hash

这是你的标签的名称0.1.2-milestone-343-f20ef9ef2d

git describe 将显示标签名称(将仅显示带注释的标签)

git show-ref --tags 也会显示散列

git describe --tag --abbrev=0会显示你想要的

这符合我的特定要求

git describe --tag --abbrev=0

--tags show lightweight tags too
--abbrev=0 removes the hash