The default branch: master vs main

Whether you are cloning an existing repo, or creating a new one, there is the notion of the "default branch".

The latest (v2) version of the git-scm book defines a branch as follows (emphasis added):

Nearly every VCS has some form of branching support. Branching means you diverge from the main line of development and continue to do work without messing with that main line. In many VCS tools, this is a somewhat expensive process, often requiring you to create a new copy of your source code directory, which can take a long time for large projects.

Some people refer to Git’s branching model as its "killer feature," and it certainly sets Git apart in the VCS community. Why is it so special? The way Git branches is incredibly lightweight, making branching operations nearly instantaneous, and switching back and forth between branches generally just as fast. Unlike many other VCSs, Git encourages workflows that branch and merge often, even multiple times in a day.

Reading on, you later find that (emphasis added)...

A branch in Git is simply a lightweight movable pointer to one of these commits. The default branch name in Git is master. As you start making commits, you’re given a master branch that points to the last commit you made. Every time you commit, the master branch pointer moves forward automatically.

The default name "master" appears in a figure following this explanation:

A branch and its commit history, taken from the git book (v2)

The Software Freedom Conservancy released a statement in June 23, 2020 called "Regarding Git and Branch Naming". The statement reads:

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’.

A blog post released on gitlab in March of 2021 called The new Git default branch name elaborates a bit further:

Every Git repository has an initial or original branch, which is the first branch to be created when a new repository is generated. Historically, the default name for this initial branch was master. This term came from Bitkeeper, a predecessor to Git. Bitkeeper referred to the source of truth as the "master repository" and other copies as "slave repositories". This shows how common master/slave references have been in technology, and the difficulty in knowing how the term master should be interpreted.

Bitbucket and many other sites that host git projects have since adopted main as the preferred term for the initial branch.

Tip

If in these tutorials or other examples you find an errant master used, please be patient as we continue to update our resources to use main consistently.

See also: