Management wants the default branch renamed from `master` to `main` without breaking everyone.
IntermediateScenarioRemotes, Collaboration and Pull Requests
Answer
Situation read → Clones, CI, deployment scripts and PRs all reference the name.
What I'd do →
- Rename in GitHub: Settings → Branches, or
gh api -X POST repos/ORG/REPO/branches/master/rename -f new_name=main. Open PRs retarget and GitHub redirects some operations. - Search the repo for hard-coded names in CI files, Dockerfiles and docs.
- Each developer runs:
git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a
- Update branch protection rules and deployment triggers.
Why → The server rename is easy; the long tail is automation referring to the old name.
Interview tip → Announce a date and keep a checklist.
More on Remotes, Collaboration and Pull Requests
You are new to a team. How do you collaborate daily without stepping on others' toes?BeginnerYou are migrating a repo from Bitbucket to GitHub and must keep every branch and tag.IntermediateYou want to contribute a fix to an open-source project you do not have write access to.BeginnerA teammate sent a 3,000-line PR and nobody can review it properly.IntermediateA reviewer asks for changes. How do you update the PR cleanly?BeginnerYour team wants stacked PRs so that large work arrives in small reviewable steps. How do you set it up?Advanced