BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News New GitHub Repositories Default to Main Branch

New GitHub Repositories Default to Main Branch

This item in japanese

Bookmarks

As of today, all newly created GitHub repositories will have a default branch of 'main' instead of 'master'. This change reflects a similar one from the upstream Git project which started the transition from using 'master' for their default branch name, allowing projects to customise what the default branch of a project is called. From the Software Freedom Conservancy announcement regarding Git and Branch Names earlier this year:

Both Conservancy and the Git project are aware that the initial branch name, ‘master’, is offensive to some people and we empathize with those hurt by the use of that term.

Existing versions of Git are capable of working with any branch name; there's nothing special about ‘master’ except that it has historically been the name used for the first branch when creating a new repository from scratch (with the git init command). Thus many projects use it to represent the primary line of development. We support and encourage projects to switch to branch names that are meaningful and inclusive, and we'll be adding features to Git to make it even easier to use a different default for new projects.

As a first step, Git will add a mechanism to allow users to specify the default used as the name of the first branch when creating a new repository. Also, consistent with its project governance, Git has undertaken a community process to explore changing the name of the first branch created automatically for new repositories away from ‘master’. That change is currently being discussed on our mailing list. As always, changes in Git's core will minimize disruption for Git's users and will include appropriate deprecation periods.

Git version 2.28 introduced a new configuration option, init.defaultBranch, that can be used to define what the default branch name is called. This defaults to `master` (for backwards compatibility) but can be configured in a user's defaults configuration, or systemwide.

Projects appear to have settled on using `main` as the preferred name for the default branch, although like `master` this is purely conventional. To support this, GitHub has announced that they will support renaming of the default branch while being able to redirect requests from deleted branchs to the new default branch name, along with supporting GitHub pages being created from a named branch instead of the default. There are also user/organisation/enterprise settings that allow customisation of the default branch name, in the same way that the client can be configured.

There are other planned enhancements, such as allowing open PRs and issues to be retargeted automatically to the default branch name, which GitHub is planning to do later in the year.

Some open-source projects have already switched their default branch to use 'main': for example, Apple's Swift programming language, along with support libraries like swift-nio and the newly released swift-system have switched to using 'main' as the default branch name. Other programming languages like Python and Rust have not yet switched.

Do you plan on renaming the default branch on GitHub?

Rate this Article

Adoption
Style

BT