Skip to site navigation
Go home

Lee Reamsnyder

Change the name of your git repository’s default branch

2020 Jun 8 1 min read Published by Lee Reamsnyder Permalink

So this is a tiny thing all considered, but I’ll feel better about myself if I’m typing master less often. These steps come from Scott Hanselman (via Jeremy Keith).

Move your master branch to a branch with a different name (I’ve chosen main):

git branch -m master main

Then push that up, updating the tracking branch in the process:

git push -u origin main

If you’re using Github, you can update the default branch on your repository by clicking Settings > Branches. Under the Default branch section, select “main” and click Update.

Netlify deploys this site whenever there’s an update to master, so I had to change that. From the site dashboard, it’s Settings > Build & deploy. In the Deploy contexts section, click Edit settings, and update the Production branch and maybe the list in Branch deploys if you’ve selected Let me add individual branches. Then, click Save.

If you’re seeing this, it worked.

← Older post Black lives matter → Newer post Donald Trump is bad and should feel bad

Menu

  • Home
  • Blog
  • Work
  • Contact
  • Archives
  • Feeds: RSS | JSON

Search

Elsewhere

  • GitHub
  • Instagram
  • Mastodon
  • Twitter
© Copyright 2006–2023, Lee James Reamsnyder
Back to top