Skip to content

Instantly share code, notes, and snippets.

@0xdade
Last active October 17, 2019 23:45
Show Gist options
  • Save 0xdade/dbb18fb4a3866de18149efbb63277cab to your computer and use it in GitHub Desktop.
Save 0xdade/dbb18fb4a3866de18149efbb63277cab to your computer and use it in GitHub Desktop.
Changing default branches on github
  1. $ git branch -m master main
  2. $ git push origin main
  3. Change "Default Branch" in Settings->Branches on github. https:github.com/your/repo/settings/branches.
  4. Accept any warnings about changing the default branch.
  5. If you have any branch protection rules that affect the master branch, delete them.
  6. $ git push origin :master
  7. If you had any branch protection rules affecting the master branch, recreate them on the main branch.
  8. Look through your repo for references to master and replace with main as necesary.
    • Examples of this include URLs to a file in the REPO that are not relative
  9. 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
  10. git add your changes
  11. `git commit -m "Rename master to main"
  12. Update any third party integrations that might be relying on the presence of the master branch, such as codeclimate or various CI/CD systems
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment