Replacing master with main in Github

afrodevgirl

Alexis Moody

Posted on June 16, 2020

Replacing master with main in Github

As a black software engineer I have often felt uncomfortable with a variety of terms used throughout the industry. Terms like master/slave, blacklist/whitelist, and black hat/white hat enforce this country's belief that white is good and black is not. We can and should be better than this.

I am the product of slaves and sharecroppers from Louisiana/Tennessee so using the term master to define the default source of truth in my repos has always caused me pain. But I got used to it because it was such a pervasive term, and every time I brought up how hurtful it was to coworkers I was met with resistance. I refuse to do so any longer. Today, I have begun the process of moving to the use of main as my default branch in all of my owned repos. So i'm here to show you how to make a change that will take 3 minutes or less and make your teams more inclusive.

Step 1 - Update Local

While on the master branch input the following:

$ git branch -m master main
$ git push -u origin main
Enter fullscreen mode Exit fullscreen mode

So what are we doing here? First with the -m command we are moving the git history from master to a new branch called main. Next we're pushing the main branch up to the origin remote, and establishing an upstream connection with the -u command.

Step 2 - Update Repo

  • Navigate to your repository > Settings > Branches
  • Select main as your default branch
  • Update your branch protection rules
  • Navigate to Code > Branches and delete master

That's literally it. I hope this guide helps you and your teams become more inclusive!

💖 💪 🙅 🚩
afrodevgirl
Alexis Moody

Posted on June 16, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related