Mike Kiev - Fotolia

Why GitHub renamed its master branch to main

The GitHub master branch is no more. Developers used to think it was untouchable, but that's not the case. Here's why GitHub made the switch from master branch to main branch.

Since its inception, the Git DVCS tool's default branch name was set to master. Every Git repository had a master branch unless a developer took explicit steps to remove it, which was rarely ever done because the master branch plays an integral role in the software development world. For most projects, the master branch represents the source of truth -- that is, all the code that works, is tested and ready to be pushed to production.

However, the term master is out of favor in the computing world and beyond. Git and GitHub weren't far behind either. Starting October 1, all new GitHub repositories will create a default branch named main, and GitHub will no longer create a master branch for you. Let's examine why GitHub renamed the master branch to main branch and what effect it will have on developers.

Cultural sensitivity

The computer industry's use of the terms master and slave caught everyone's attention in the summer of 2020. Amid the many protests and the growing social unrest, these harmful and antiquated terms were no longer considered appropriate.

"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," said the Software Freedom Conservancy.

GitHub took action based on the Conservancy's suggestion and moved away from the term master when a Git repository is initialized, "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 result, GitHub renamed the master branch to main branch.

Git master install
Git version 2.29 introduced the ability to switch the default branch name from master to main

In practice, there's never been anything special about Git's master branch. However, the branch is so ubiquitous that users often believe that it can't be deleted or removed from a project without harming the repository. These are false assumptions. The master branch is no different than any other branch in a cloned Git repo, except that historically it's been the default name used when the first branch is created. A developer can delete, rename and even re-create the master branch after it's deleted, just like any other Git branch.

The GitHub switch from master to main

The change isn't retroactive and won't affect any existing projects. Also, if GitHub users want to add a branch named master to their repository, there is nothing to stop them. GitHub only discourages the term -- it does not ban the term.

Important DevOps tools

Of course, any project hosted on GitHub that expects a master branch to exist will run into problems. For example, if a developer creates a new repository with GitHub's own Jekyll-based website hosting tool GitHub Pages, it's still configured to look for static content on a master branch that doesn't exist.

However, this will soon be updated. All attempts to access GitHub Pages on a newly created repository will fail until a developer changes the settings so it serves Pages from the main branch instead of master. It's easy to fix, but it also serves as a reminder that there may be some unexpected blips as GitHub renames its master branch.

It's a one-time engineering cost that will have lasting impacts.
Whitney SorensonChief architect, HubSpot

One researcher says the change will do little to alter projects, and there will be next to no effect on his research group's workflow.

"I really appreciate the name change [because] it raises awareness," said Javier Cánovas, assistant professor in the SOM Research Lab, at the Internet Interdisciplinary Institute at the Open University of Catalonia in Barcelona. "There are things that we accept as implicit, and we then realize that we can change them because they don't match our society."

For Whitney Sorenson, chief architect at HubSpot in Cambridge, Mass., the benefits of GitHub renaming the master branch to main far outweigh any temporary stumbling blocks. He said the change is part of a broader internal initiative to add inclusive language to the company's systems. His team is also replacing whitelist and blacklist with allowlist and blocklist.

"While it takes time to make these changes now, it's a one-time engineering cost that will have lasting impacts, both internally and externally," Sorenson said in an email. "We're in this for the long game, and we know inclusive language is just as much about how we code and what we build as it is about person-to-person interactions."

Cameron McKenzie also contributed to this report.

Next Steps

GitHub hires first-ever chief security officer

How to create a GitHub repository

Dig Deeper on DevOps-driven, cloud-native app development

App Architecture
Software Quality
Cloud Computing
Security
SearchAWS
Close