Skip to content

Instantly share code, notes, and snippets.

@shawnbot
Last active June 12, 2020 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawnbot/b0d50eb562f051dd614ed0e89b073af7 to your computer and use it in GitHub Desktop.
Save shawnbot/b0d50eb562f051dd614ed0e89b073af7 to your computer and use it in GitHub Desktop.

You should rename the master branch to main in git, and on GitHub. Here's how!

1. Create your new main branch

...with one click on github.com/:owner/:repo:

image

2. Update the default branch to main in your repo's branch settings

Visit github.com/:owner/:repo/settings/branches, then:

image

3. Update any relevant branch protection rules

On the same page as step 2, above:

image

4. Update the base branch in all of your open pull requests against master

Visit github.com/:owner/:repo/pulls?q=is%3Apull+is%3Aopen+base%3Amaster, then:

a. Click the "Edit" button:

image

b. Change "base: master" to main:

image

5. Delete your master branch

Visit github.com/:owner/:repo/branches, then click on the trash can for the master row:

image

If the trash can is grey, then you've probably still got pull requests with master as their base branch. Go back to step 4.

5. Update your git clones

cd path/to/project
git pull --ff --prune
git checkout main
git branch -d master

6. Fight systemic racism and white supremacy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment