GitHub’s default branch naming convention

What is a branch ?

Let’s say you’ve been working on a project and have been committing it, but now you want to try out new things without impacting the current build this can be done by creating something called a branch. Changes done here won’t have any impact on your current build, and if you feel that the new feature is something you want in your build and it works fine you can merge it with your main branch and have your project deployed.

GitHub’s newly adopted default main branch

Ever since GitHub changed it’s default repository branch name from “master” to “main” (due to slavery references) its caused quite an uproar. The reason being that GitHub’s default branch name not matching your local branch name which still is “master”.

Method’s to conquer master vs main Issues:

Method 1 :
In GitHub you can go to your repository settings and change the default name of the branch back to “master”. This will basically revert the workflow back to how it was prior change and no issues should rise.

Method 2 :
Change the default local branch name to “main”. This can be done using git’s very own config command. The following is the syntax.

git config --global init.defaultBranch main

After updating the default branch to “main” you could use the following commands to pull and push from remote repository.


git pull origin remoteServerName

prior default name change,

git pull origin master

after name change,

git pull origin main


git push -u origin localBranchName

prior default name change,

git push -u origin master

after name change,

git push -u origin main

Method 3 :
Instead of changing default names, you can leave everything as it is and do the following,

Connecting and pulling from the remote server
Checkout/switching to main branch

After establishing connection with the remote server, your next step is to pull changes from the remote to your local repository. When this is done we inevitably pull all the branches present in the remote repository, even if they do not show up when we use the following

git branch -a

So we can use the “checkout” or “switch” command to switch between branches

git checkout main

both the above mentioned commands will switch the branch to the “main” branch.

Method 4 :
Without making any changes to default branches and continuing as normal. We can create a new branch and call it “main”, switch to it and continue the process by replacing “master” with “main

Here are different ways to create new branch and switch to it

git branch main
git switch main

These are some of the methods that I used to get over the master vs main issues.

Aspiring Game Developer with experience in the field of Machine Learning.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store