Git

How to Rename “main” Branch to “master” on a GitHub Repository?

On GitHub, developers create multiple branches to work/collaborate on the same development project simultaneously. Each branch has its own code that can be merged/combined into the main branch. Branches help developers in parallel development, adding new features, bug fixing, etc. Moreover, developers can rename the remote branches on GitHub.

This write-up will discuss the method for renaming the “main” branch to “master” on the GitHub repository.

How to Rename the “main” Branch to “master” on a GitHub Repository?

To rename the “main” branch to “master” on the GitHub repository, follow the provided steps:

  • Navigate to the particular GitHub repository. 
  • View the list of remote branches.
  • Choose the “main” branch and open it.
  • Select the edit option.
  • Rename “main” to “master”.
  • Click on the “Rename branch” button.

Step 1: Display Remote Branches

First, display the list of all existing remote branches. For instance, it can be seen that our remote repository contains only one “main” branch:

Then, click on the below-highlighted button and navigate to it:

Step 2: Edit “main” Branch

After that, click on the highlighted icon to edit the current branch:

Step 3: Rename Branch

First, remove the existing branch name. For instance, we will rename the “main” branch:

Next, specify the new name of the branch in the required field. In our case, we have entered “master”. Then, press the “Rename branch” button:

Here, it can be seen that the particular branch has been renamed to “master”:

Step 4: Verification

Lastly, move back to the remote repository to check whether the previous branch renames action has been performed successfully or not:

According to the given output, the default branch has been renamed to the “master” successfully.

Conclusion

To rename the “main” branch to “master” on the remote repository, first, redirect to the particular GitHub repository and display the list of its branches. Then, click on the “branch” button and navigate to it. Next, edit the branch and rename it to the “master”. Lastly, press the “Rename branch” button to save changes. This article explained the method to rename the “main” branch to “master” on the GitHub repository.

About the author

Laiba Younas

I have done bachelors in Computer Science. Being passionate about learning new technologies, I am interested in exploring different programming languages and sharing my experience with the world.