How to Change Default Branch in GitHub (Step-by-Step Guide)
If you want to learn how to change default branch in GitHub, this guide will help you. It will teach you how to switch the default branch using both the GitHub website and Git commands on your computer.
Table of contents
How to Change Default Branch on GitHub?
1. Change Default Branch on GitHub Website
Follow these steps directly from your repository settings:
- Open your repository on GitHub.
- Click Settings from the top menu.

- Go to Branches in the left sidebar.
- Under Default branch, click the edit button.
- Select the new branch from the dropdown.

- Confirm by clicking Update.
Your repository now uses the new branch as the default.
For related tasks, you may also want to learn how to create a folder in GitHub.
2. Change Default Branch with Git Locally
If you prefer working with the terminal:
- Open your terminal and navigate to your repo folder.
- Rename the branch (example: master to main):
git branch -m master main
- Push the renamed branch to GitHub:
git push -u origin main
- Delete the old branch from the remote:
git push origin --delete master
Afterward, update the default branch in the GitHub settings as shown above.
If you run into merge problems while switching branches, see this guide on how to resolve conflicts in GitHub.
Why Change the Default Branch?
The default branch is where all new pull requests and commits point. You may want to switch from master to main, or use another branch as the main development line.
FAQs
You can rename it locally, push the change to GitHub, and then update the default branch in the repository settings.
No. The old branch still exists until you manually delete it.
Yes. Pull requests will redirect to the new branch, so notify your team before making the switch.
Yes. You can change the default branch again in the settings at any time.
Conclusion
Learning how to change default branch in GitHub is simple and ensures your project stays organized. You can update it in a few clicks on the GitHub website or by using Git commands locally. For more, check out how to approve a pull request in GitHub.
Read our disclosure page to find out how can you help Windows Report sustain the editorial team. Read more
User forum
0 messages