LoginSignup
2
2

More than 5 years have passed since last update.

ブランチの存在意義がわからなくならない為に

Last updated at Posted at 2019-03-08

そのブランチ何のためのものだっけ....?

ローカルの古いブランチ整理とかしている時に果たしてそれが消していいものかそうでないものなのかわからなくなった.....というかもうリリースは終わっているんだっけ。。。。?
プロジェクトメンバーにもブランチ整理する為に不要なブランチを教えるように伝えたが同じような反応.....

ってことでそのブランチが何の為に存在していたのか,そのブランチのリリースタイミングいつだったっけってわかる方法ないかなぁ

って調べてたら

gitのブランチに説明をつけることができるみたいなのでそのやり方をご紹介

説明追加方法

git branch --edit-description

$ git branch --edit-description {ブランチ名}

上記コマンド実行すると↓のようなテキストエディット画面が開くので好きなようにメモを書きましょう

# Please edit the description for the branch
#   feature/sugita_working_branch
# Lines starting with '#' will be stripped.

適当に入力↓

test
test

https://qiita.com

# Please edit the description for the branch
#   feature/sugita_working_branch
# Lines starting with '#' will be stripped.

確認方法

git config branch.{ブランチ名}.description

$ git config branch.{ブランチ名}.description

上記コマンドで↓のように先ほど入力したメモが表示される

$ git config branch.{ブランチ名}.description
test
test

https://qiita.com

一個難点

git config branch.{ブランチ名}.description て入力するの面倒すぎるだろうぇぇぇぇ....

なのでエイリアスをつける

エイリアス

自分が作業する時にリポジトリ関わらず反映させたいので ~/.gitconfig に登録する

ちなみにエイリアスの適応範囲は以下

適応範囲 設定ファイル
リポジトリ {リポジトリのディレクトリ}/.git/config
ユーザー ~/.gitconfig
システム全体 /etc/gitconfig
[alias]
        show-branch-description = "!f(){ git config branch.$(git rev-parse --abbrev-ref ${1:-@}).description;};f"

これで↓のコマンドでメモを表示することができる

$ git show-branch-description {ブランチ名}
test
test

https://qiita.com

活用方法としては

  • 関連チケットのURL貼る
  • リリースタイミング記載する
  • プロジェクト名記載する

↑でだいぶわかりやすくなるかなと思います。

個人的にすごいわかりやすくなってよかった

おわり

2
2
1

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
2
2