根据最近的标签描述当前提交
git describe 从最近的 tag 推导版本字符串,常用于构建版本号、制品命名和发布脚本。它依赖标签历史,浅克隆或没有 tag 时会退化。
git describe --tags
git describe --tags --always
git describe --tags --dirty
git describe --tags --long
git describe --tags --match 'v*'
git describe --tags --exact-match
git describe --tags --abbrev=12 HEAD
git describe --tags --first-parent
--tags。--always 退回短哈希。--dirty 才会显示后缀,否则版本看起来是干净的。--long 强制输出 tag-距离-g哈希,适合需要精确提交的制品。--match 能过滤 tag 前缀,避免被无关标签干扰。git — 版本控制git-archive — 导出源码goreleaser — 基于 tag 发布