LoginSignup
6
2

More than 5 years have passed since last update.

gitのコミットやタグがブランチとどう関連するか確認する

Last updated at Posted at 2018-05-18

gitのコミットやタグがブランチとどう関連するか確認する

問題

gitのタグが分るが、そのタグが打たれたブランチが分らないとき。
あるいは、あるコミットがどのブランチのものなのか不明なとき、などの作業記録。

解法

こちら1の情報から次のようなことをして確認

追記:ローカルにチェックアウト済みでないとうまくいかない場合もあるかもしれないので、注意して利用のこと。

# その1
# タグ(ハッシュでもよい)が含まれるブランチ一覧
# リモートも含めて調査させるなら -a 
$> git branch --contains <TAG_ANY>

# その2
# タグのハッシュ確認
$> git show <TAG_ANY>
# ハッシュ指定版
$> git branch --contains <hash>

# その3
# あるハッシュがどのブランチ/タグにあるか、検出できるものを出す
$> git name-rev <hash>
# あるハッシュ/タグが指定ブランチのどの位置(最新の何個前)(ex.ここではmaster)
$> git name-rev --refs master <hash>

参照

6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2