Git rename branch
![](https://richrose.dev/images/github-logo.png)
The following blog post covers how to rename the default branch in GitHub. If you have wondered how to do this task it is basically two discrete steps.
-
- Rename the default branch
-
- Update the local clone
Once complete the branch will be available and response as the default.
Rename Default branch
The default branch configuration can be changed from the GitHub interface. From the GitHub interface select the repo to update
- Go to the repo setting option
- Select the
Branches
option - Rename the Default branch to whatever you like
Local Clone
With the default branch renamed the local clone also needs to be updated. In the below example the default MASTER branch is being renamed to MAIN.
GitHub recommend the following to update the local clone:
1git branch -m master main
2git fetch origin
3git branch -u origin/main main
4git remote set-head origin -a
Alternatively delete the local repo and repull a local clone.