How to set a default branch in GitHub

GitHub is one of the most commonly used version control collaboration software in the development community.

Branches

Branches allow users to develop in an isolated environment without affecting the rest of the repository. Each repository has a main branch, and all other branches come from existing branches. To merge the work on two or more branches, you must use a pull request.

Default branch

The default branch on the new repository is set to main, as it is the first and only branch on your repository at that time. The default branch is the one that is displayed to anyone viewing your repository. This is also the branch that will be checked outthe branch that will be made active locally when someone clones your repository to their computer.

You can change the default and set a different branch for pull requests and new commits.

Changing default branch

If you only want to change the name of the default branch, look into renaming the branch. The process of changing the default branch is highlighted below.

Your branch must have more than one branch for the default branch to change.

  1. Go to the main page of your repository on GitHub, and click on “Settings”.
widget
  1. When you get to Settings, in the left menu, click on the option Branches.
widget
  1. Click on the two arrows next to the ‘Default branch’ heading.
widget
  1. On the pop-up, click main to reveal available options in the drop-down menu. Select the branch you want to set as the new default branch and click Update.
widget
  1. Read the warning that pops up and click on ‘I understand’.

You have successfully changed your default branch.

widget
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved