This document outlines steps needed to migrate the default branch
of your repo from master
to main
.
Note: This document is currently a work in progress.
If you have questions about the process, reach out to the GitHub Management Team on the #github-management channel on slack or open an issue in the kubernetes/org repo.
Create an issue in your repo to track the branch rename. You can paste this checklist in the issue body.
If you are not a root approver for the repo, assign a root approver for approval.
Once the issue has been approved, send a notice to your SIG’s mailing list about the potential branch rename.
Make the following changes before renaming the branch the master
branch.
Note: There might be additional changes required that have not been covered in this checklist.
Note: There might be additional information available in the umbrella issue via [kubernetes/org#2222].
These changes are non-disruptive and can be made anytime before renaming the branch.
If a presubmit or postsubmit prowjob triggers on the master
branch
(branches
field of the prowjob), add the main
branch to the list
(see kubernetes/test-infra#20665 for an example).
If the milestone_applier
prow config references the master
branch,
add the main
branch to the config (see kubernetes/test-infra#20675 for an example).
If the branch_protection
prow config references the master
branch,
add the main
branch to the config.
These changes are disruptive and should be made just before renaming the branch.
For periodic prowjobs, or any prowjob that mentions the master
branch
in base_ref
, update them to the main
branch. Ensure that these changes
happen in lock-step with the branch rename (jobs triggered in between landing
these changes and renaming the branch will fail).
kubernetes/foo=main
. kubernetes/test-infra#20667 may eventually
allow for non-disruptive changes.base_ref: main
. kubernetes/test-infra#20672 may eventually allow
for non-disruptive changes. If a prowjob mentions master
in its name, rename the job to not include
the branch name, e.g. pull-repo-verify-master
-> pull-repo-verify
.
status-reconciler
should automatically migrate PR status contexts to the
new job name, and retrigger accordingly, but we have anecdotally found it
sometimes misses changes.
If a prowjob calls scripts or code in your repo that explicitly
reference master
, update all references to use main
, or auto-detect the
remote branch
# for existing clones, update their view of the remote
git fetch origin
git remote set-head origin -a
# for new clones, or those updated as above, this prints "main" post-rename
echo $(git symbolic-ref refs/remotes/origin/HEAD)
# gh is https://github.com/cli/cli, this will print "main" post-rename
gh api /repos/kubernetes-sigs/slack-infra | jq -r .default_branch
If the repo has netlify configured for it, ask a member of the GitHub
Management Team to rename the master
branch to main
in the netlify site config.
It can’t be controlled through the netlify config in the repo.
master
to main
using the GitHub UI
by following the official instructions.After the default branch has been renamed to main
, make the following
changes.
Note: There might be additional changes required that have not been covered in this checklist.
master
branch in the branches
field,
remove the master
branch (see kubernetes/test-infra#20669 for an example). If the milestone_applier
prow config references the master
branch,
remove it from the config.
If the branch_protection
prow config references the master
branch,
remove it from the config.
If any docs reference the master
branch, update to main
(URLs will be automatically redirected).
Ensure that CI and PR tests work fine.
Trial the local development experience with a pre-rename clone.
ma<tab>
will autocomplete to main
Send a notice about the branch rename to your SIG’s mailing list. Include the link to the GitHub instructions to rename your local branch.
Was this page helpful?