Default Git Branch Name with Learn Enough and the Rails Tutorial
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 GitHub’s instructions for new repositories use main
instead of master
, including a command that changes the default branch name on the local repository (Figure 1). This can be especially confusing because Git itself still uses master
.

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 master
→ main
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

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, using master
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 github.com/settings/repositories:
- Sign in to your GitHub account.
- Go to github.com/settings/repositories.
- Select the field with the default name
main
(Figure 3). - Change
main
tomaster
(Figure 4). - 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.

main
default branch name at GitHub.

master
.

master
in Git refers instead to the notion of a master recording.