| title | Changing the default branch | ||||||
|---|---|---|---|---|---|---|---|
| intro | If you have more than one branch in your repository, you can configure any branch as the default branch. | ||||||
| permissions | People with admin access for a repository can change the default branch for the repository. | ||||||
| versions |
|
||||||
| redirect_from |
|
||||||
| shortTitle | Change the default branch | ||||||
| category |
|
You can choose the default branch for a repository. The default branch is the base branch for pull requests and code commits. For more information about the default branch, see AUTOTITLE.
You can also rename the default branch. For more information, see AUTOTITLE.
{% data reusables.branches.set-default-branch %}
To change the default branch, your repository must have more than one branch. For more information, see AUTOTITLE.
{% ifversion repo-admin-branch-rename %}
If organizational or enterprise rulesets target branches in your repository, changing the default branch requires an organization or enterprise administrator. Whether repository administrators can rename other targeted branches depends on the branch-rename setting or policy configured by your organization or enterprise. For more information, see AUTOTITLE.
{% else %}
Rulesets at the organization level that apply to branches of a repository will not allow the repository administrator to rename branches of the targeted repository or change the default branch to another branch. See AUTOTITLE.
{% endif %}
Additionally, you need to have admin access to a repository to change the default branch.
{% data reusables.repositories.navigate-to-repo %} {% data reusables.repositories.sidebar-settings %}
- Under "Default branch", to the right of the default branch name, click {% octicon "arrow-switch" aria-label="Switch to another branch" %}.
- Select the branch dropdown menu and click a branch name.
- Click Update.
- Read the warning, then click I understand, update the default branch.