It’s About Time We Rename Our Git Repos’ Primary Branches from Master to Main
Git historically used the term “
master" for the primary branch. This master-slave metaphor, as pointed out by the Internet Engineering Task Force (IETF) is "an oppressive metaphor" and that it "should never become fully detached from history". They continue by saying that "In addition to being inappropriate and arcane, the master-slave metaphor is both technically and historically inaccurate."
The IETF also gives a list of different relationships that you can use instead of master-slave. These include:
- Primary & secondary
- Leader & follower
- Active & standby
- Primary & replica
- Writer & reader
- Coordinator & worker
- Parent & helper
While they refer to these as alternatives, it is better to not call them alternative phrases to the master-slave connotation. The term alternative in and of itself leads to the presumption that whatever two or more objects you are comparing are equal in value. This would technically imply that primary-secondary for example, and master-slave, are equally valid, even when they are quite clearly not.
Regardless of personal preference, the “master-slave” connotation is one that a lot of people will not want to have to look at or deal with, given the historic meaning of the phrase.
Fortunately, renaming the “master” branch to something else is not really that difficult of a task. Since GitHub is using “main” as their replacement for “master”, and since it would be good for muscle memory with the amount of people that do “ma “, I willll use “main” in my example as well.
git branch -m master main
git push -u origin main
You will now have a new branch “main”. You will also now need to set it as the default and remove the “master” branch. You will now want to update the default branch on GitHub by going to the repo you want to edit, tapping or clicking “settings”, going to “branches”, and following the on-page instructions for changing the default branch.
If you need to update local clones, you can do so with the below commands according to xunit.net:
git checkout master
git branch -m master main
git branch --unset-upstream
git branch -u origin/main
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
Hopefully the code provided here helps. If you do not want to use “main”, you can always use branch names such as “latest”, “development”, and so on. Git is decentralized, and does not have requirements specifying what the default branch name needs to be.
Originally published at https://www.antonmcclure.com on November 3, 2020.