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:
- Head over to your repository.
- Click on Settings -> General -> Default branch.
- Hit Edit and change the branch name to "main."
In this screenshot, I’ve already made the change, but yours should look pretty similar!
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
Thanks for reading my article :)
Happy coding, and don’t hesitate to share your thoughts.
Top comments (0)