Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to add a descriptive label to a Git branch? [duplicate]

Tags:

git

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.

like image 689
JoGr Avatar asked Aug 19 '11 05:08

JoGr


2 Answers

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
like image 156
Ryan Bigg Avatar answered Oct 25 '22 13:10

Ryan Bigg


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

like image 1
Philip Oakley Avatar answered Oct 25 '22 13:10

Philip Oakley