DEV Community

Cover image for Renaming your master branch to main in GithubπŸ‘©β€πŸ’»

Renaming your master branch to main in GithubπŸ‘©β€πŸ’»

Jane Tracy πŸ‘©πŸ½β€πŸ’» on September 06, 2020

How I learned about the main branch When I started to code in March this year, I have always used the master branch as my default branch...
Collapse
 
thinkverse profile image
Kim Hallberg

Git v2.28 introduced the init.defaultBranch config so now you can also set it locally as well. πŸ‘Β πŸ™‚

$ git config --global init.defaultBranch main
Enter fullscreen mode Exit fullscreen mode

Github wrote a blog post about that you can read - "Introducing init.defaultBranch". πŸ˜€

Collapse
 
tracycss profile image
Jane Tracy πŸ‘©πŸ½β€πŸ’»

Thank you, Kim, for adding that.
I didn't know about it. πŸ”₯

Collapse
 
tcelestino profile image
Tiago Celestino

It's nice!!!

Collapse
 
goodevilgenius profile image
Dan Jones

I will continue to maintain that main is not a useful name. Neither is master, and has other problematic implications. So, I'm certainly not advocating using master.

The thing is, we name all of our other branches according to their purpose, so why not the default branch? In my opinion, the default branch should also be named according to how it's used.

For projects where the default branch represents the stable code, it should be named something like stable, or prod. I usually use prod for continuously deployed web apps, and stable for versioned projects.

For projects where the default branch represents the main development branch, it should be named develop or development.

Collapse
 
tracycss profile image
Jane Tracy πŸ‘©πŸ½β€πŸ’»

Thanks for your input, Dan. βœ”
Yes, it's true.
Different teams or organization name their branches differently. πŸ’―πŸŒŸ
Develop branch is common especially for features underdevelopment etc.

Collapse
 
goodevilgenius profile image
Dan Jones

I do. In all my projects. πŸ˜ƒ

Collapse
 
nathanhannon profile image
Nathan Hannon • Edited

Someone created a cool web app/tool to automatically rename the default remote branches in all your repositories: eyqs.ca/tools/rename

Collapse
 
tracycss profile image
Jane Tracy πŸ‘©πŸ½β€πŸ’»

That's amazing. Thanks for sharing Nathan. πŸ™Œ

Collapse
 
tracycss profile image
Jane Tracy πŸ‘©πŸ½β€πŸ’»

Hey, you can use the link I provided in the post to take a look. πŸ’―

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