How can I rename git branch master to main?
I see that many projects are moving from
What is the easiest way to rename the
master branch to
How can I rename it also on the Github repo without breaking things?
Should I do it for all projects or I can keep using
master (all my projects use branch
Many people are moving from branch
Personally I find this change meaningless and confusing — nobody thinks to slavery when you talk about master and slave in computer science and it is just a convention! Also note that
master is still the default name for Git.
In any case if you want to follow the majority of companies that are changing the name from
main, you can do it with one simple command:
$ git branch -m master main
Then you can ensure that you are on branch
After the change you can use:
$ git push origin main
Note that also the other commands will change. For example if you want to push on Heroku:
$ git push heroku main
Finally… If you ever want to switch back from
master you can also do it: just switch the position of
main in the
git branch command.
Note that for Git the branch
main) doesn’t have any special meaning, it’s just a branch like any other.