Branch Names
The name you assign to a branch is essentially arbitrary,
though there are some limitations. The default branch in a repository is
named master
, and most developers keep the repositoryâs most robust
and dependable line of development on that branch. There is nothing
magical about the name master
except that Git
introduces it during the initialization of a repository. If you
prefer, you can rename or even delete the master
branch, although itâs probably best practice to leave it alone.
To support scalability and categorical organization, you can create a
hierarchical branch name that resembles a Unix pathname. For example,
suppose you are part of a development team that fixes multitudes of
bugs. It may be useful to place the development of each repair in a
hierarchical structure under the branch name bug
, on
separate branches named something
like bug/pr-1023
and bug/pr-17
. If
you find you have many branches or are just terminally over-organized,
you can use this slash syntax to introduce some structure to your branch
names.
Tip
One reason to use hierarchical branch names is that Git, just
like the Unix shell, supports wildcards. For instance, given the naming scheme
bug/pr-1023
and bug/pr-17
, you
can select all bug
branches at once with a clever
and familiar shorthand.
git show-branch 'bug/*'
Dos and Donâts in Branch Names
Branch names must conform to a few simple rules:
You can use the forward slash (
/
) to create a hierarchical name scheme. However, the name cannot end ...
Get Version Control with Git now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.