$ git branch -m master main
$ git push origin main
- Change "Default Branch" in Settings->Branches on github. https:github.com/your/repo/settings/branches.
- Accept any warnings about changing the default branch.
- If you have any branch protection rules that affect the
master
branch, delete them. $ git push origin :master
- If you had any branch protection rules affecting the
master
branch, recreate them on themain
branch. - Look through your repo for references to
master
and replace withmain
as necesary.- Examples of this include URLs to a file in the REPO that are not relative
- If you get a warning "Your branch is based on 'origin/master', but the upstream is gone." then use the command it recommends:
git branch --unset-upstream
git add
your changes- `git commit -m "Rename master to main"
- Update any third party integrations that might be relying on the presence of the
master
branch, such as codeclimate or various CI/CD systems
Last active
October 17, 2019 23:45
-
-
Save 0xdade/dbb18fb4a3866de18149efbb63277cab to your computer and use it in GitHub Desktop.
Changing default branches on github
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment