brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: git branch --edit-description stores a note about what a branch is for

Git
~/tips/tip-git-branch-edit-description

git branch --edit-description [<branch-name>]

Saves a free-text description for a branch, so you remember later what it was meant to do.

A branch called fix-stuff made sense on Tuesday. Three weeks later it is a mystery. Branch names are short by nature, and Git has a built-in place for the longer explanation that nobody uses.

git branch --edit-description [<branch-name>]

Git opens your editor. Write what the branch is for, save, and close it. The text may run over several lines, and per the documentation other commands use it, among them format-patch, request-pull and merge (if enabled). The description is stored in the configuration as branch.<name>.description, so you can read it back without the editor:

git config branch.left.description
Feature for tips
second line

To list all of them at once, ask for the whole key pattern:

git config --get-regexp 'branch\..*\.description'

In a repository with descriptions set, this prints one line per branch that has one, with the key and the text. Branches without one do not show up.

The docs say the description is added automatically to the cover letter of git format-patch and to the summary of git request-pull, which makes it useful when you send patches by mail.

Caveats. The description lives in your local .git/config. It is not pushed, so it will not appear on the remote or for your colleagues. After git branch -m left left2, the description shows up under branch.left2.description, which fits the docs saying a rename moves the branch together with its config.

Further reading: git-branch documentation

More Git tips git show-branch main feature git log --stat -5 git merge --no-ff feature -m "Merge feature" git merge --squash feature git merge --abort All Git tips (144) All topics

Link