Changing your default branch - all the places

You can also read my blog post on changing the default branch stream upstream in git or renaming your own default branch in GitLab.

This post is a living post where I document all the different places where one may need to update the default branch when changing the name of that branch.


All the Places


Scott Hanselman wrote a great post about renaming your branch and updating GitHub.


See my previous post on updating GitLab.


If you deploy to Netlify using their standard git connection, you'll need to tell Netlify you've updated the default branch (what they call the production branch).

  1. Log in and find the site you just updated
  2. Go to Deploys
  3. Click Deploy Settings
  4. Under Deploy contexts click Edit settings
  5. Change the name of the production branch and click Save
Note: There may still be a "branch deploy" for master after you click save. You can remove this by just editing the settings one more time and removing master from the "Let me add individual branches" section.

GitLab CI/CD

It's possible if you use GitLab CI/CD, then a simple find/replace of master in your .gitlab-ci.yml will be sufficient. However, you could make your builds future proof by using environmental variables that come built-in.

For example, you may have code that says

Old Code

    - master

Here, we could simply update master to the new name, but if we also look at the updated rules: functionality, we could refactor this to something like:

New Code


This allows us to use the variables GitLab provides to explicitly say, "run this job only on the default branch." Then, our CI configuration will respect any future changes to the default branch.