Meaningful and Inclusive - Renaming "master" Branch to "main"

Stephen Baker

,

Senior Developer

March 24, 2022

Since June 2020, many companies have begun making the switch in Git, deleting the “master” branch in favor of “main”. I wanted to take a closer look at why.

What is Git?

According to the official website:

“Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.”

Essentially, it’s a tool that allows development teams to sync their code all together based on a single source-of-truth. Since Git was released in 2005, collaboration within dev teams has never been easier.

Services like Github, Bitbucket, and GitLab utilize Git to provide cloud hosting for your code repositories (repos). Your entire company’s codebase lives on servers that these services manage for you. This allows dev teams to focus on what they do best - code. Once setup in this way, all a developer must do is:

  1. Create a new repo in the cloud service chosen. This repo is basically your project and houses all of the code for it.
  2. Git clone that new repo to their local machine where they have already installed Git.
  3. Make some changes to the code.
  4. Git commit those changes locally. Once this step is done, even if the code files you just changed are deleted, your changes will still be recoverable.
  5. Git push your committed code up to the cloud for your team to gain access to.

Git Branches

Now that we understand high level what Git is, it’s important that we also grasp what branches within a repo or project are. Technically, a branch is a pointer to a commit made within your repo.

What this means practically is: branches allow for multiple versions of project code. A typical application will, at minimum, have a dev, staging, and main/master branch that may all be the same but don’t have to be.

Git branching diagram
Diagram by Bitbucket

In the diagram above, we have our primary branch (Main) in light blue. That is the source-of-truth and is the exact code that should be running in a live environment. Each circle represents a separate commit made to the code.

When a developer wants to add a new feature, they create a new branch based off of the Main branch (just like Little Feature and Big Feature above). By doing this, they can ensure that their code only gets into production once fully tested and intentionally merged back into the Main branch. It also allows multiple features to be developed by multiple developers all in tandem.

master vs. main

The default branch name for all Git repositories around the world from inception to early 2020 was master.

Almost immediately after the tragic murder of George Floyd on May 25th, 2020, protests began to spread across the United States. Support for Black Lives Matter grew, and the topic of racial equality was at the forefront of everything. NASCAR announced it would ban Confederate flags from its events and properties. Quaker Oats discontinued its Aunt Jemima brand name.

And then on June 23rd, 2020, Software Freedom Conservatory made an announcement regarding Git and branch naming. The statement is brief but they recognize that the default branch name of master is “offensive to some people” and then go on to say:

“We support and encourage projects to switch to branch names that are meaningful and inclusive…”

The dev community took notice of this and more companies joined the fold. One of the biggest influencers in this space was probably GitHub due to their sheer market size after they posted their commitment to renaming.

It’s Just a Word

As a developer, I remember looking at all of these changes and thinking people were blowing things out of proportion. At the time, I was working for a different company that had 30+ repositories all containing a master branch. It seemed like this unnecessary change that had a lot of risk and no obvious benefit. The only people who would even know we made the change were the internal developers since our repositories were all private. And it was my understanding that Git only named it master to mean “master copy of the code”.

To top it off, people from all ethnic backgrounds started speaking out against the GitHub announcement. A petition was even signed by over 3,800 people in hopes that GitHub would change their mind on the renaming, stating “actions like these are completely irrelevant. They are distractions, not solutions.”

I rationalized that there was no reason to make my life more difficult as a developer and to keep using the branch master. I even created a couple new repositories with a master branch almost as a way to “make my point” about how ridiculous all this was.

When I started here at TCG Machines in January, 2021, naturally every repo had a master branch. As I created new repos, I finally started using a main branch mainly to fall in line with the way the world was moving but not because I had bought-in to the call-for-action yet. So I still didn’t see any reason to convert our existing repos over.

Then, the other day, I stumbled across this breaking changes announcement on the express-winston npm page. They posted it back in 2020 but when I saw it, I was reminded of the renaming initiative and decided to dig a little deeper.

express-winston v5 breaking changes
express-winston v5 Breaking Changes

Git’s Predecessor BitKeeper

Git was invented 15 years ago by Linus Torvalds, creator of the Linux kernel. It was a response to mounting issues around using BitKeeper, the original distributed source management system, and no other scm’s being suitable for Linux kernel development at the time. That project is now completely open-source and hosted on GitHub so we have full public access to the entire codebase!

In the documentation, there are references to “slave” repositories. Learning from the issues BitKeeper had going for it, Git was built to be very much like BitKeeper but faster and, most importantly, free. Git decided to still use the master branch naming but forewent all references to slave right out-of-the-gate. Still, it’s pretty hard to ignore the similarities between the Git master branch and the BitKeeper usage of master/slave.

BitKeeper slave term usage in documentation
BitKeeper "slave" term usage in their documentation

Conclusion

We may never know for certain whether the original intention of Git’s master branch was for it to be a “master copy” of code, or the master in a master/slave relationship. Either way, I can now say that all TCG Machines repos are using a main branch and all master branches have been deleted.

We also went through and made sure there are no references to “whitelist” or “blacklist” in our codebase either. Instead, we have decided to follow Apple’s lead with their naming and go with “allow list” and “deny list”. It may not be much, but it’s something that we are in control of and honestly wasn’t that difficult to change.

< Back to Articles