I have recently published two articles, How to get started with Git and GitHub in your windows machine and How to import your company's private repository from Bitbucket into GitHub, and I remembered that GitHub, the Microsoft acquired source code hosting application, will be renaming its default repository branch master to main by October 2020.

The reason for renaming is to remove references to slavery and replace it with a more inclusive term. Using master in GitHub does not mean that they refer to slavery, but it is the origin of the term master that is the concern.

This means any repository created from October 1, 2020, will automatically use main as the default branch and NOT master.

However, those repositories created before the above date will have the same default branch, and this change will not affect them.

If you think the change by GitHub is likely to affect your workflow, you can dictate your default branches from your GitHub settings;-

See screenshot below

The bad or good news is that  by the end of the year 2020, all existing repositories still using master as their default branch will be changed to main.

Before that is done, you need to do it yourself to avoid disruption on your git workflow, in case GitHub's automated tools make a mistake. You can checkout this article if you do not know what git workflow is, How to get started with Git and GitHub in your windows machine.

Proceed as follows;-

step 1: Rename old branch, master to new branch, main using the -m option

git branch -m master main

step 2: Update remote repository using -u option to add upstream (tracking) reference.

git push -u origin main

step 3: Login to your GitHub account and change your default branch to main. See the video below.

Changing your default branch in GitHub

 step 4: Now you can delete the master branch, in the remote repository  

git push origin --delete master

I hope you enjoyed converting your repositories default branch form master to main.

Now you are inclusive :)

You've successfully subscribed to Decoded For Devs
Welcome back! You've successfully signed in.
Great! You've successfully signed up.
Your link has expired
Success! Your account is fully activated, you now have access to all content.