このツイートの通りです。
git branch --edit-description [<branchname>] でブランチにメモが付けられる!
— 神速@リリカルエンジニア (@sinsoku_listy) 2017年9月12日
そして、 git config branch.<branchname>.description で表示できる!使い所は知らない! https://t.co/xt2P7MdUYa
使い方
下記のコマンドを実行するとエディタが起動し、説明を書けます。 <branchname>
を省略すると、現在のブランチに対してメモが書けます。
$ git branch --edit-description [<branchname>]
メモを表示するコマンドは下記の通りです。 <branchname>
はメモを表示したいブランチ名です。
$ git config branch.<branchname>.description
使いづらいけど、仕方ありません。Git のコマンドはそんなものです。
git alias
ブランチの説明を簡単に表示するエイリアスを作ってみました。
[alias] # git show-description [<branch_name>] show-branch-description = "!f(){ git config branch.$(git rev-parse --abbrev-ref ${1:-@}).description;};f"
これで少し使いやすくなると思います。
注意
ブランチの説明はローカルリポジトリのブランチに対するもので push はできません。
本来の用途
ヘルプを読むと、ブランチの説明は format-patch
や request-pull
、merge
のコマンドで使うようです。
引用元: git help branch
–edit-description Open an editor and edit the text to explain what the branch is for, to be used by various other commands (e.g. format-patch, request-pull, and merge (if enabled)). Multi-line explanations may be used.
引用元: git help merge
merge.branchdesc In addition to branch names, populate the log message with the branch description text associated with them. Defaults to false.
format-patch
や request-pull
はあまり使わずよく分からないので、ためしに merge で使ってみました。
merge で使う
まず、マージで使えるようにするために下記の設定をします。
$ git config merge.branchdesc true $ git config merge.log true
この状態で説明の付いているブランチをマージすると、自動でブランチの説明がコミットメッセージに挿入されます。
Merge branch 'feature' into dev * feature: : ブランチの説明 2nd commit message 1st commit message # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
なるほど、便利そうな雰囲気あるけど、やっぱり使い所は思い浮かばない。
ブランチをたくさん使う人には便利かもしれません。