Skip to main content
Antal István

Guides1 min read

Changing the Default Branch from Main to Master on GitHub

Change a GitHub repo default branch from main to master: local setup, CI/CD updates, and troubleshooting.

A subway-map diagram of yellow station circles along a main line, with blue and green branch lines splitting off, a yellow flag at the end, and a red lever beside it.

In empty repositories

git branch -M master
# Make your initial commit
git commit
git push -u origin master

In non-empty repositories

Navigate to your repository on GitHub and follow these steps:

  1. Go to your repository's main page
  2. Click on Settings (requires admin access)
  3. Under "Default branch", click the switch icon or pencil icon
  4. Type master in the textbox
  5. Click Rename branch

Related reading