DEV Community

Cover image for Master -> Main branch in 2024
Vidya🌞
Vidya🌞

Posted on

Master -> Main branch in 2024

Hey there!

As we all know, in October 2020 git community made a meaningful change by deciding to shift the default branch name from "master" to "main."

Personally, I didn't have any problem using "master" as the default branch name. However, as we keep upgrading ourselves in tech, it was inevitable to accept this change and rename our "master" branch to "main," incorporating the "main" branch in our new repositories.

Today, I was checking an old repository that I created back in 2019, and it was mostly empty. I decided to repurpose that same repository for my new projects, so I chose to change the "master" branch to "main" since I’m used to it now.

Now we'll look into simple steps to rename "master" -> "main"

Using the GitHub Interface:

  1. Head over to your repository.
  2. Click on Settings -> General -> Default branch.
  3. Hit Edit and change the branch name to "main."

img-2

In this screenshot, I’ve already made the change, but yours should look pretty similar!

devops-cloudnative-projects-ss

Updating Your Local Clone

If you’ve got a local clone of the repo, don’t worry—you can easily update it too! Just run these commands in your terminal:

git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a
Enter fullscreen mode Exit fullscreen mode

Thanks for reading my article :)

Happy coding, and don’t hesitate to share your thoughts.

Top comments (0)