You can rename a branch in a repository on GitHub. For more information about branches, see "About branches."
When you rename a branch on GitHub, any URLs that contain the old branch name are automatically redirected to the equivalent URL for the renamed branch. Branch protection policies are also updated, as well as the base branch for open pull requests (including those for forks) and draft releases. After the rename is complete, GitHub provides instructions on the repository's home page directing contributors to update their local Git environments.
Although file URLs are automatically redirected, raw file URLs are not redirected. Also, GitHub does not perform any redirects if users perform a
git pull for the previous branch name.
- ファイルのリストの上部で NUMBER branchesをクリックしてください。
- In the list of branches, to the right of the branch you want to rename, click .
- Type a new name for the branch.
- Review the information about local environments, then click Rename branch.
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 branch -m OLD-BRANCH-NAME NEW-BRANCH-NAME $ git fetch origin $ git branch -u origin/NEW-BRANCH-NAME NEW-BRANCH-NAME