git describe
git
用法
git describe [--tags] [--dirty]以最近的标签为基准,把当前提交命名成 v1.2.0-5-gabc1234 这样;默认只看附注标签,轻量标签要加 --tags,一个标签都没有时要加 --always。
常用选项
| 选项 | 含义 |
|---|---|
| --tags | use lightweight tags too, not just annotated ones |
| --dirty | append -dirty when the working tree has changes |
| --always | fall back to a bare hash when no tag is found |
| --long | always the full tag-count-hash form |
| --abbrev=<n> | how many hash digits to print |
| --match <pattern> | only consider matching tags |
示例
git describe --tags --dirtyprints something like v1.2.0-5-gabc1234-dirty
git describe --alwaysnever fails, even in a repository with no tags
git describe --match "v*" --longignores tags that are not versions
难的地方在于撤销有好几种:把分支的指向挪走,和补一个反向提交,不是一回事。
怎么看
- 方括号 [ ] 表示这部分可以不写。
- 省略号 … 表示可以写多个。
- 选项区分大小写——有些命令里 -r 和 -R 不是一回事。
常见问题
Q. git describe 是做什么的?
以最近的标签为基准,把当前提交命名成 v1.2.0-5-gabc1234 这样;默认只看附注标签,轻量标签要加 --tags,一个标签都没有时要加 --always。
Q. 怎么写?
git describe [--tags] [--dirty] —— 方括号表示可以省略的部分。
Q. 值得记的选项有几个?
这里列了 6 个,完整列表在 man git。这条命令属于git。
相关命令
man 手册: man git-describe