From ‘master’ to ‘main’: The easy guide to renaming your Git default branch for a more inclusive codebase
I started heavy development on Firecode.io this week to get it out of beta — and one of the first changes I had to make was renaming my primary branch to “main”. In 2020, Github announced that it would be dropping the use of the term “master” for the default branch name on its platform. This decision was made in response to calls for more inclusive language in tech, as “master” has historical connotations of slavery and domination. The change has been supported by many in the tech industry who recognize the importance of taking small but significant steps towards creating more inclusive spaces for everyone.
Since Github is one of the most popular code hosting platforms, this change has had a ripple effect across the tech industry. Many companies and organizations have followed suit and made the switch from “master” to “main” for their default branch names. This has involved going through a series of steps to rename the branch, update links, and make sure that the change is reflected in all relevant places.
Making this change is actually quite simple and should only take a couple of minutes:
Step 1: Create a new branch
The first step is to create a new branch called
main from the existing
git branch -m master main
This command renames the
master branch to
Step 2: Push the new branch to the remote repository
Next, you need to push the new
main branch to the remote repository:
git push -u origin main
This command pushes the new
main branch to the remote repository and sets up tracking so that future
git push and
git pull commands work as expected.
Step 3: Point the HEAD to the new branch
The next step is to point the HEAD to the
main branch. You can do this using the following command:
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main