Interview Prep/Git & GitHub/Remotes, Collaboration and Pull Requests

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 →

  1. 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.
  2. Search the repo for hard-coded names in CI files, Dockerfiles and docs.
  3. Each developer runs:
git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a
  1. 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.

All Git & GitHub questions Roadmap: Git & GitHub

More on Remotes, Collaboration and Pull Requests