9

Possible Duplicate:
Branch descriptions in git

Is there any way to add a description to a Git branch? I'd like to keep my branch names fairly short, but sometimes it would be useful to list them with some short description attached.

Community
  • 1
  • 1
JoGr
  • 1,457
  • 11
  • 22

2 Answers2

2

You can do this with git notes:

 git notes add your_branch -m "BRANCH_DESCRIPTION: A descriptive name for this branch"

Then you can read it back out using this command:

 git notes show your_branch

You can store your notes as a file and use that instead, switching the -m option for the -f option and of course passing a filename rather than a string.

 git notes add your_branch -f mynotes.txt
Ryan Bigg
  • 106,965
  • 23
  • 235
  • 261
  • 1
    Thanks, that eases it up some. Still it would be nice to be able to list all branches with the notes next to them. – JoGr Aug 19 '11 at 06:28
  • 5
    I think this is a misleading, I'm afraid - git notes can only be added to objects, so this is actually adding the note to the commit which was at the tip of `your_branch` when the command was run, rather than to the branch. Once you've added more commits to `your_branch`, `git notes show your_branch` will no longer work. I think a better solution is [the top voted answer on the question Luwe linked to](http://stackoverflow.com/q/2108405/223092). – Mark Longair Aug 19 '11 at 07:02
  • Yes, indeed. It doesn't quite work the way I wanted when I follow my normal workflow. I'll check out the linked question... – JoGr Aug 19 '11 at 08:06
1

The place to add your branch descriptions & name should be in the merge commit notes. This is because branches should be short lived, and their branch tip(s) can't be guaranteed to last forever.

The time you really need them (descriptive branch names) is when you have to review an old history that has merges on it and after that branch head(tip) has been deleted, etc. And you need more clues as to what it was all about (aka you should have written better commit messages ;-)

Thus the merge commit would list the branches names/details of the parent branches (especially No2, No3, .., as No 1's name will either be 'master', or will show up in a later merge).

Remember, the branch name and description is a convenience, not a necessity. I'm sure that there are posts by Linus T to that effect (usually with some emphasis ;-)

You already get some help on branch names .. how-to-avoid-merge-branch-name-of-branch-in-commit-messages

Community
  • 1
  • 1
Philip Oakley
  • 13,333
  • 9
  • 48
  • 71