Renaming a branch

You can change the name of a branch in a repository.

People with write permissions to a repository can rename a branch in the repository. People with admin permissions can rename the default branch.

In this article

About renaming branches

You can rename a branch in a repository on GitHub. For more information about branches, see "About branches."

If you rename a branch, GitHub will automatically redirect links on that contain the old branch name to the equivalent link on the renamed branch. GitHub will also update branch protection policies, as well as the base branch for open pull requests and draft releases.

Renaming a branch

  1. On GitHub, navigate to the main page of the repository.
  2. Above the list of files, click NUMBER branches.
    Branches link on overview page
  3. In the list of branches, to the right of the branch you want to rename, click .
    Pencil icon to the right of branch you want to rename
  4. Type a new name for the branch.
    Text field for typing new branch name
  5. Review the information about local environments, then click Rename branch.
    Local environment information and "Rename branch" button

Updating a local clone after a branch name changes

After you rename a branch in a repository on GitHub, any collaborator with a local clone of the repository will need to update the clone.

From the local clone of the repository on a computer, run the following commands to update the name of the default branch.

$ git fetch origin
$ git branch -u origin/NEW-BRANCH-NAME NEW-BRANCH-NAME

Did this doc help you?

Privacy policy

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

Or, learn how to contribute.