Until recently, almost every Git repository had a default branch named “master”. But thankfully, as part of a movement to make the tech industry more inclusive and open, many software teams and open source projects are moving away from this unhealthy naming.

There has been quite some debate about a good replacement. And while “default” and “primary” had been interesting candidates, most of the Git community seems to agree that “main” should be a good successor for the outdated “master”.

Many Git hosting platforms like GitHub, GitLab, or Bitbucket will soon make changes on their end (or, depending on when exactly you read this post, they might already have done so). In the near future, if you create a new Git repository on any of these platforms, you will find “main” to be the new default branch.

But what about your current, existing projects? That’s exactly what we’ll be talking about in this post: how you can rename “master” to “main” in your existing Git repositories!

Step 1: Rename Your Local master Branch

The first step is to rename the local “master” branch in your local repositories. You can do that easily with the following command:

$ git branch -m master main

Let’s make sure this has worked:

$ git branch * main

Perfect! Our local branch has been renamed, but we now have to do the same on the remote side of things.

#git #github #gitlab #bitbucket #hackernoon-top-story #rename-git-repositories #make-tech-inclusive #rename-git-repo-master-to-main

How To Rename Your Git Repositories From "Master" to "Main"
2.85 GEEK