Branch descriptions in Git
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Git allows you to add descriptions to local branches using git branch --edit-description. Branch descriptions provide context about the purpose of a branch — what feature is being developed, what issue it addresses, or its current status. While not widely used, they can help teams keep track of branch purposes in repositories with many active branches.
Setting a Branch Description
Reading a Branch Description
Create an alias for convenience:
How Git Stores Descriptions
Branch descriptions are stored in .git/config as branch configuration:
They are local only — descriptions are not pushed to remote repositories.
Practical Use: Branch Listing with Descriptions
Create a script to list branches with their descriptions:
Output:
Branch Descriptions in merge/request-pull
Git uses branch descriptions automatically in certain commands:
Branching Strategies
Branch descriptions are useful within these common branching strategies:
- Gitflow Workflow: A branching model that leverages feature, release, and hotfix branches to streamline development. Descriptions help distinguish between multiple active feature and hotfix branches.
- GitHub Flow: A simpler, more modern strategy that uses branches primarily for feature development, always keeping the main branch deployable. Descriptions can note the linked PR number.
- Trunk-Based Development: All developers work on a single branch (often the main) with short-lived feature branches merged in rapidly. Descriptions help clarify the purpose of very short-lived branches.
Alternatives to Branch Descriptions
Since descriptions are local-only, teams often use other conventions:
Branch Naming Conventions
PR/MR Descriptions
GitHub, GitLab, and Bitbucket provide PR descriptions that are shared with the team and linked to the branch.
Git Notes
Common Pitfalls
- Not shared remotely: Branch descriptions are stored in
.git/configand are not pushed to remote repositories. Team members will not see your descriptions. - Lost on branch deletion: When you delete a branch, its description is also removed. There is no history of branch descriptions.
- Editor requirement:
git branch --edit-descriptionopens a text editor. Set your preferred editor withgit config --global core.editor "code --wait"or similar. - No built-in listing: There is no native
git branchflag to show descriptions alongside branch names. You need custom scripts or aliases. - Multiline descriptions: Descriptions can be multiline, but
git configreads only the first line by default. Use--getto retrieve the full description.
Summary
- Set branch descriptions with
git branch --edit-description - Read with
git config branch.<name>.description - Descriptions are local only — not shared when pushing to remotes
- They appear in
git merge --log,git request-pull, andgit format-patch - For team-wide context, rely on branch naming conventions and PR descriptions instead

