You can now rename any branch, including the default branch, from the web.
If you've been waiting to rename your default branch from
main, we now recommend doing so using this feature.
When a branch is renamed:
- Open pull requests and draft releases targeting the renamed branch will be retargeted automatically
- Branch protection rules that explicitly reference the renamed branch will be updated
Note: admin permissions are required to rename the default branch, but write permissions are sufficient to rename other branches.
To help make the change as seamless as possible for users:
- We'll show a notice to contributors, maintainers, and admins on the repository homepage with instructions for updating their local repository
- Web requests to the old branch will be redirected
- A "moved permanently" HTTP response will be returned to REST API calls
- An informational message will be displayed to Git command line users that push to the old branch
This change is one of many changes GitHub is making to support projects and maintainers that want to rename their default branch. Branch names will not change unless the maintainer explicitly makes the change, however this new rename functionality should dramatically reduce the disruption to projects who do want to change branch names. To learn more about the change we've made, see github/renaming.
To learn more, see Renaming a branch