I came across git branch descriptions today and it is so freakin useful that I wanted to share.
My branches usually look like this:
$ git branch add-feature feature-add * implement-foo implement-foo2 temp temp2
It is… not the clearest. Luckily, you can add descriptions to branches:
$ git checkout implement-foo2 $ git branch --edit-description ---Pops up an editor--- These are the tests for my implement-foo change, they can be cherry-picked onto implement-foo when they are done. ---Save & exit---
The only problem is that these descriptions don’t show up when you do
git branch. To display them, use jsageryd‘s script (and vote up the comment, it should really be nearer the top):
#!/bin/bash branches=$(git for-each-ref --format='%(refname)' refs/heads/ | sed 's|refs/heads/||') for branch in $branches; do desc=$(git config branch.$branch.description) if [ $branch == $(git rev-parse --abbrev-ref HEAD) ]; then branch="* \033[0;32m$branch\033[0m" else branch=" $branch" fi echo -e "$branch \033[0;36m$desc\033[0m" done
Save it as something (I called it “branch”), make it executable, add it to your path, and then you can do:
$ branch add-feature feature-add implement-foo * implement-foo2 These are the tests for my implement-foo change, they can be cherry-picked onto implement-foo when they are done. temp temp2
It’s even got nice colors for the selected branch and descriptions.