Default Git Branch Name with Learn Enough and the Rails Tutorial

Guidance on choosing a default Git branch name

Oct 24, 2020 • posted by Michael Hartl
This is a short post explaining how the current state of the default Git branch name in the Learn Enough tutorials and the Ruby on Rails Tutorial. This post will be updated as necessary should the current situation change. For more a detailed discussion of version control with Git, see Learn Enough Git to Be Dangerous.

For the meat of this post, you can skip right to Section 2.

The Git version control system is designed to help you track changes in projects. As part of this, Git allows you to create separate “branches” for particular sets of project changes, which can then be incorporated (or merged) back into the default branch.

Ever since the initial release of Git in 2005, this default branch has been called master. Some developers, concerned about possible negative associations with this term, have advocated for using a different name for the default branch, such as trunk, default, or main.1

In particular, as of October 2020, developer platform GitHub announced that new repositories will use main by default. In practice, this means that the default instructions for new repositories use main, including a command that changes the default branch name on the local repository (Figure 1), which can be confusing because Git itself still uses master.

Figure 1: The instructions for a default repository at GitHub.

Because of GitHub’s importance to the developer community, this change represents a complication for a significant fraction of Git users, including those who follow the Learn Enough tutorials. On the other hand, unexpected changes happen all the time in software development, so this is also an excellent chance to apply one of Learn Enough’s core principles, technical sophistication. In the rest of this post, we’ll discuss two possible solutions resulting from an application of this principle.

1 Going with GitHub

The path of least resistance is simply to go with GitHub’s new default and use main (as seen, e.g., in Figure 1). In this case, you will have to replace master with main in most existing Git documentation, including the Learn Enough tutorials and the Ruby on Rails Tutorial.

Given the large amount of effectively immutable Git-related content (including print books, previously downloaded ebooks, and videos), making this mastermain substitution will be necessary for a long time to come, but luckily it’s not too difficult. As noted previously, this is an excellent chance to exercise your technical sophistication.

2 Changing back

A second possibility is to use GitHub’s own capabilities to change the default branch name back to master, at least temporarily. The resulting default GitHub instructions will then use master in place of main (Figure 2).2

Figure 2: GitHub’s new repo instructions for a restored default of master.

This choice brings GitHub back into agreement with Git itself, which still uses master by default for newly created repositories (via git init). In addition, this choice ensures maximum compatibility with existing documentation, including the Learn Enough tutorials and the Ruby on Rails Tutorial, and thus makes for a smoother learning experience.

Updating GitHub settings

Changing the GitHub default from main back to master simply requires editing a single form, located at

  1. Sign in to your GitHub account.
  2. Go to
  3. Select the field with the default name main (Figure 3).
  4. Change main to master (Figure 4).
  5. Click “Update”. The result should be as shown in Figure 5.

With this change made, GitHub’s instructions for a new repository will now appear as in Figure 2, and your results using Git will match those shown in the Learn Enough tutorials and the Ruby on Rails Tutorial.

Figure 3: The new main default branch name at GitHub.
Figure 4: Changing back to the default branch name master.
Figure 5: The updated default branch name.
1. Although initial discussions were influenced by controversy surrounding the use of master/slave terminology in technology, in fact the use of master in Git refers instead to the notion of a master recording.
2. Because Git’s own default branch is still called master, the command git branch -M master in Figure 2 attempts to change master to master, so it won’t actually do anything right now. It does no harm to include it, though, and 100% guarantees that the local and remote branch names agree exactly.
learnenough-news , git , github