DEV Community

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

How to rename your master branch to something else

Saeed Ahmad on June 17, 2020

Well, we all might have heard that GitHub will remove the master naming convention for default branch. Source: https://www.bbc.com/news/technol...
Collapse
 
moopet profile image
Info Comment hidden by post author - thread only accessible via permalink
Ben Sinclair

I'm happy for people to rename "master" to "main" (or "production" or whatever you want, but there's no "master-slave naming convention for branches" at the moment. I've never seen a project with a branch called "slave". The picture you included implies that people conventionally use a branch called "slave" and I think that's misleading. I know the BBC article doesn't help, but when people look back at articles like this in years to come, they're going to get, at the very least, an inaccurate impression of history.

People use "slave" terminology for things like database replicas, hard drive connections, etc., and changing the names there could be a good improvement, at least going forward.

Collapse
 
rzr666 profile image
Info Comment hidden by post author - thread only accessible via permalink
RZR666

Nope I've never seen a slave branch either. It's becoming a bit ridiculous now.

Collapse
 
moopet profile image
Info Comment hidden by post author - thread only accessible via permalink
Ben Sinclair

I'm not trying to say people shouldn't do it, I'm pointing out that this specific instance is not representative.

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
Info Comment hidden by post author - thread only accessible via permalink
Daniel Ziltener

This is one of the most stupid things I've heard of in a loooong time.

Some comments have been hidden by the post's author - find out more