Reputation: 895
GitHub has started to change the name of the default branch from master to main. Now, the default branch in my remote repository is called main instead of master.
However, my local repository has the default branch named master, and if I commit and push changes, it uploads it to a new branch (called master) instead of uploading it to the default branch (called main).
I know there is some controversy in the use of master as the name of the default branch, but I have some commands automatized after many years of using git like "git push origin master", or "git checkout master".
Is there any way of setting the default branch name to master instead of main? I know how to change the repository name in my local repository and in GitHub, but now, each time I create a new repository, the default branch is main, and when I do "git init" in a directory, the default branch is master, so I have to manually change it.
Upvotes: 5
Views: 938
Reputation: 535989
but now, each time I create a new repository, the default branch is main, and when I do "git init" in a directory, the default branch is master, so I have to manually change it.
That isn't exactly true. If you create a new empty repository at GitHub, and then, back at your local, you git init
and add-and-commit and push, the master
from your local goes up to GitHub just fine, and no main
is ever created at local or at GitHub.
Moreover, even if main
on GitHub does get created (e.g. because you added a Readme when you configured the repo at GitHub), nothing prevents you from hooking master
on local to main
on GitHub, so you could even just keep both and have them correspond to one another just fine.
Basically what I'm saying is that this fear at main
of GitHub is generally overdone. There is actually nothing to worry about.
Upvotes: 4
Reputation: 895
I finally figured it out. You can set the default name for the default branch in GitHub in:
Settings->Repositories.
There, there is a section called "Repository default branch" that says:
"Choose the default branch for your new personal repositories. You might want to change the default name due to different workflows, or because your integrations still require “master” as the default branch name. You can always change the default branch name on individual repositories."
Here you can change the default branch name from main to any name you want, including master.
Upvotes: 5