Skip to main content

Updating Netlify deployments when renaming your main Git branch

Posted in Development and Git

When you rename your Git branch, it’s going to break any deployments you’ve got set up. That’s because they’re configured to trigger when you push changes to your old master branch, which doesn’t exist any more.

In Netlify, it’s pretty straightforward to change the deployment branch to main (or primary or whatever you like!); just head to your site in the control panel then:

  1. Navigate to ‘Site settings’ from the main menu
  2. Choose ‘Continuous Deployment’ (inconsistent case sic) in the side menu, in the ‘Build & deploy’ grouping
  3. Scroll to ‘Deploy contexts’, the second section down the page
  4. Where you see ‘Production branch’ with the old branch name, hit the ‘Edit settings’ button
  5. Change the value ‘Production branch’ to the new branch name and save the changes

That’s it! The next time you push to your renamed branch, Netlify will publish your site.

Get them delivered!

If you enjoyed this and want all the latest articles delivered to your inbox every month, pop your email in the form below.

I don’t collect any data on when, where or if people open the emails I send them. Your email will only be used to send you newsletters and will never be passed on. You can unsubscribe at any time.

More posts

Here are a couple more posts for you to enjoy. If that's not enough, have a look at the full list.

  1. The difference between strikethrough and del

    Just like <em> and <i>, and <strong> and <b>, the distinction between <s> and <del> is subtle, but it’s worth knowing.

  2. Git restore to discard changes

    I no longer use git checkout to switch branches; I’ve also stopped using it to discard uncommitted changes: let me introduce git restore!