Home / Snippets / How to Rename the master branch to main in Git
How to Rename the master branch to main in Git cover

How to Rename the master branch to main in Git

122

2 years ago

0 comments

So you might just init git repository locally and the branch by default is set to "master". Since many of the git online repositories make use of "main" as the default one now, you'll have to rename it.

The command to change the branch name is like below, use "-m" flag to modify the branch name.
git branch -m master main

Now the branch name will be called "main" and you can push it to the online repository.
git push --set-upstream origin main
notion avatar

Ahmad Aziz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Post Tutorials

Learn trending tutorials for ReactJs, React Native, VueJS, NextJs, Laravel, Tailwind CSS, and Flutter development.
View Tutorials

Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that's right for your web projects
View Components

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this