views:

228

answers:

7

Is there a way in git to have a 'description' for branches? While I try to use descriptive names, working for a while on a single branch sometimes dampens my memory of why I made some of the other topic branches. I try to use descriptive names for the branches but I think a 'description' (short note about the purpose of the branch) would be nice.

A: 

I am pretty sure that feature is not currently supported. I think your best bet is to create a description text file, a README basically, in the branch that has the information that you want.

Chris J
I'd have to worry about (not) merging this file across branches. Wouldn't I?
Noufal Ibrahim
+4  A: 

The README suggested by Chris J can work, provided it is setup with a custom merge driver defined in a .gitattribute.
That way, the local version of the README is always preserved during merges.

The "description" for branches is also know as a "comment" associated with that meta data, and it is not supported.

At least, with a README file, you can, for any branch, do a:

$ git show myBranch:README

If your REAMDE is at the root directory of your REPO, it will work from any path, since the path used by git show is an absolute one from the top directory of said repo.

VonC
Cool. This is useful. Thanks.
Noufal Ibrahim
A: 

The selected answer seems like overkill to me. I'd be inclined to maintain a per branch description file that is a normal source controlled file, say master.txt, dev.txt, etc. and if there is an unwieldy number or branches I'd create a hierarchy to better organize it.

pajato0
+1  A: 

You can attach comments to tags:

git tag -m 'this was a very good commit' tag1

By convention, you could have tags related to your branch names or you could use tag -f to keep a commented tag at the head of your topic branches.

Jamey Hicks
A: 

I had a similar problem. I use that file to document branches and why they exist (among other things).

themis
A: 

Since branches are mostly illusional in git (just a local handy name for a commit that you might want to use as a parent someday), why bother? Sounds like you need some other meta information somewhere.

Randal Schwartz
Well, I'm not totally sure. I sometimes end up with branches the reason for which I've forgotten. And extra 'info' field would be nice.
Noufal Ibrahim