Git supports an option to the branch command called --edit-description which it states is used by "various" other commands. One command (at least by default) that it is not used by is git branch (when used to simply list the local branches). Is there a way to get git branch to show the branch descriptions (the verbose option looks like it just adds the last commit on the branch)?
To be clear, I'd like something like the following
> git branch
* master I am the alpha and the omega
bugfix1 This is the fix to that thing
future Transition to the new architecture
To show description of a branch, use command git config branch. <branch name>. description .
1 : a part of a tree that grows out from the trunk or from a main division of the trunk. 2 : something extending from a main line or body like a branch a branch of a railroad. 3 : a division or subordinate part of something a branch of government The bank opened a new branch.
You can use git branch --contains to list all the branches descended from the tip of develop , then use grep to make sure feature is among them. If it is among them, it will print " feature" to standard output and have a return code of 0.
A branch is a secondary wood limb growing from the trunk of a plant. It helps transport materials from the tree trunk to the leaves.
I confirm there is no way for now to display the description of the branch with git branch
(as opposed to git config
, see last part of this answer below).
This thread includes
The coming v1.7.9 will introduce branch description, mainly used in integration process. I think we could make it useful for users who don't extensively use request-pull/format-patch. Showing a short summary along with branch name in "
git branch
" would be nice.I agree that it would be nice to give users access to the information even if the branch ends up being merged to the master branch by you and never leaves your repository by itself.
You however are misguided to say "Showing a short summary along...".
The branch description support is to give users a place to record detailed explanation about a branch, similar in size to what you would normally place in a log message of a commit or a cover letter of a series.
There wasn't any convenient place to do so for a branch that is (1) inherently a moving target while it is being developed and (2) is not a good match for tags and notes.There already is a good place for a brief summary and it is called "branch name". Name your branches just like you name your functions.
The suggested patch "git branch --verbose-format
" is not yet completed.
So the script mentioned by poke, remains (with a git alias
) one possible solution:
#!/bin/perl
$output= `git branch`;
foreach my $line (split(/^/, $output)) {
my ($is_current, $name) = split(/\s+/, $line);
my $description = `git config branch.$name.description`;
$description =~ s/\s+$//;
printf("%1s %-22s %s\n", $is_current, $name, $description);
}
Philip Oakley suggests in the comments:
You can display the branch description using a
git config
command.To show all branch descriptions, I have the alias
brshow = config --get-regexp 'branch.*.description'
, and for the current HEAD I have
brshow1 = !git config --get "branch.$(git rev-parse --abbrev-ref HEAD).description".
Hit this on terminal. This will display branches with description if your branch has some description.
Step 1:
vi ~/.bashrc
Step 2: Put this
alias git-describe-branches='for line in $(git branch); do
description=$(git config branch.$line.description)
if [ -n "$description" ]; then
echo "$line $description"
fi
done'
Step 3:
source ~/.bashrc
Step 4:
git-describe-branches
OR
for line in $(git branch); do
description=$(git config branch.$line.description)
if [ -n "$description" ]; then
echo "$line $description"
fi
done
Note:
Run this in git working directory.
Will show description if your branch has description.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With