DEV Community

Cover image for How to rename your master branch to something else
Saeed Ahmad
Saeed Ahmad

Posted on

20 9

How to rename your master branch to something else

GitHub Master to Main

Well, we all might have heard that GitHub will remove the master naming convention for default branch.

Source: https://www.bbc.com/news/technology-53050955

GitHub's Twitter page posted that it stands with the black community and the fight against racism.

There are many people who might be looking to rename their branch to something more clearer and better.

First of all let's understand what a master branch is?

In Git, "master" is a naming convention for a branch. After cloning (downloading) a project from a remote server, the resulting local repository has a single local branch: the so-called "master" branch. This means that "master" can be seen as a repository's "default" branch.

Why we are doing this?

The master-slave relationship in technology usually refers to a system where one - the master - controls other copies, or processes.

The years-old campaign to replace such terms has been given fresh impetus amid the resurgence of Black Lives Matter protests in the United States.

Mr Friedman's announcement came in a Twitter reply to Google Chrome developer Una Kravets, who said she would be happy to rename the "master" branch of the project to "main".

"If it prevents even a single black person from feeling more isolated in the tech community, feels like a no-brainer to me," she wrote. (Excerpt from BBC Report)

What are potential alternate names for master branch?

Alternate names can be:

  • main
  • edge
  • release
  • prod
  • production
  • live
  • default
  • head
  • primary
  • top

How to rename master branch to some other name?

Let's name our master branch to release

i. Checkout your master branch

git checkout master

ii. Create your release branch and switch to it

git branch release
git checkout release

iii. Push that to the server

git push origin release

iv. Delete the master branch reference on the server

git push origin :master

v. Delete the local master branch

git branch -d master

Your thoughts!

Let me know what can be a more better name for master branch?

Share your ideas in the comments section so that it's easier for new developers and programming community to decide the alternative or I must say original names for both terminologies.

Thank you for reading

🖤 #BlackLivesMatter 🖤

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (21)

Collapse
 
moopet profile image
Ben Sinclair
Comment hidden by post author
Collapse
 
rzr666 profile image
RZR666
Comment hidden by post author
Collapse
 
moopet profile image
Ben Sinclair
Comment hidden by post author
Collapse
 
moopet profile image
Ben Sinclair • Edited

@mrsaeeddev if you're going to hide my comment, could you reply to it here? I'm happy for you to correct me, but I don't get why you'd want to hide this.

Collapse
 
mrsaeeddev profile image
Saeed Ahmad • Edited

Because master-slave is a general computer science term that is not specific to branches. So, I've seen many people using branches other than master as slave branches. I already had a long discussion with another person here on the same topic. Since I removed the world slave altogether from the post after reservations of people like you so, I feel there's no need for more discussion on this topic. It will only spark controversy. My personal motive behind this post is to support BLM movement and I don't want to spark any heated debates relating to it or any other topic. I hope it is clearer now.

Collapse
 
codemouse92 profile image
Jason C. McDonald

I'll be adopting devel for my team's repositories, complementary to our fresh and stable branches.

Collapse
 
ben profile image
Ben Halpern

We're looking at...

edge (master)
testing (alpha)
release (beta)
stable
Collapse
 
codemouse92 profile image
Jason C. McDonald

Oooooo, I like edge even better than devel. I think I'll have to discuss this with my team.

The beautiful upshot of renaming master is that we can reopen some important conversations about repository workflow. We've all taken the master branch for granted, but we all use it differently. Perhaps its time we change that, and perhaps this will help.

Thread Thread
 
mrsaeeddev profile image
Saeed Ahmad

Yeah exactly. Now, we can rethink our strategies regarding that.

Collapse
 
mrsaeeddev profile image
Saeed Ahmad

I really like these names. Thank you for sharing Ben!

Collapse
 
mrsaeeddev profile image
Saeed Ahmad

Oh yes. These names sound good too.

Collapse
 
roshnet profile image
Roshan Sharma

Hey, nice post!
I'd like to add a bit though
git branch -m master main
to rename, followed by a push also seems to work fine.

Collapse
 
mrsaeeddev profile image
Saeed Ahmad

Thank you so much. I'll try this one-liner. This is more concise.

Collapse
 
jessehouwing profile image
Jesse Houwing • Edited

Careful though... I did this on one repo where, as it turned out the master wasn't up to date with origin. So, from that moment on, I relied on branching from
origin/master instead of my local master after performing a fetch.

Thread Thread
 
mrsaeeddev profile image
Saeed Ahmad

I haven't tried it yet but thank you for pointing this out.

Collapse
 
matthewadams profile image
Matthew Adams

Surprised you didn’t suggest “trunk”.

Collapse
 
mrsaeeddev profile image
Saeed Ahmad

Oh yes. It sounds great.

Collapse
 
matthewadams profile image
Matthew Adams

...and goes back a long, long way.

Collapse
 
mrsaeeddev profile image
Saeed Ahmad • Edited

Well, I'd prefer to name them as main (master), dev, test, and feature. I think to name them like that because it is more clear for the team. Even it's for the other people, you just look at the branch name and you get its purpose.

Collapse
 
zilti_500 profile image
Daniel Ziltener
Comment hidden by post author

Some comments may only be visible to logged-in visitors. Sign in to view all comments. Some comments have been hidden by the post's author - find out more

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more