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