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.
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
).
Deploys
Deploy Settings
Deploy contexts
click Edit settings
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.
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
only:
refs:
- 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:
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
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.