Playbook: Fix Default Branch (master→main, main→dev)
When to use
repo-consistency-audit.mdreportsdefault branch is 'master'- New PRs on GitHub target wrong base branch
- Worker queue creates PRs to
maininstead ofdev - Repo onboarded before ecosystem standard was established
Branch standard (p24-infra ecosystem)
| Branch | Role |
|---|---|
main | Protected — tagged releases only. Never commit directly. |
dev | Integration branch — all PRs target here. Default branch on GitHub. |
feat/*, fix/* | Feature/fix branches — branch from origin/dev, PR back to dev |
rc/vX.Y.Z | Release candidate — created from dev, merged to main |
Exception: p24-infra itself uses main as default (infra repo, single main line).
Scenario A — Rename master → main
Used for: amazon-kdp-tango (default branch is master, never had main)
$repo = "radieu/<repo>"
$local = "d:\code_2026\<repo>" # adjust path
# 1. Create main from master locally
git -C $local checkout master
git -C $local checkout -b main
# 2. Push main to remote
git -C $local push origin main
# 3. Set main as default on GitHub
gh api "repos/$repo" -X PATCH -f default_branch=main | Out-Null
Write-Host "Default branch set to: main"
# 4. Verify
gh repo view $repo --json defaultBranchRef --jq ".defaultBranchRef.name"
# 5. Delete master on remote (only after confirming main is correct)
git -C $local push origin --delete master
Write-Host "master deleted from remote"
# 6. Update local tracking
git -C $local branch --set-upstream-to=origin/main mainWarning: Deleting master will break any open PRs targeting it, bookmarks, CI configs
referencing master. Check first:
gh pr list --repo $repo --base master --json number,title | ConvertFrom-Json
# If any open PRs: retarget them before deletingScenario B — Add dev branch and set as default
Used for: Art-Agency, radekkonarski-personal-brand, et-operational-platform
(these have main but all PRs should target dev per ecosystem standard)
$repo = "radieu/<repo>"
$local = "C:\code_2026\<repo>" # adjust path
# 1. Check if dev already exists
$devExists = git -C $local ls-remote --heads origin dev
if (-not $devExists) {
# Create dev from current main
git -C $local checkout main
git -C $local pull origin main
git -C $local checkout -b dev
git -C $local push origin dev
Write-Host "dev branch created from main"
} else {
Write-Host "dev branch already exists"
}
# 2. Set dev as default branch on GitHub
gh api "repos/$repo" -X PATCH -f default_branch=dev | Out-Null
Write-Host "Default branch set to: dev"
# 3. Verify
gh repo view $repo --json defaultBranchRef --jq ".defaultBranchRef.name"Note: Setting dev as default means:
- New PRs default to targeting
dev✅ - GitHub “home” page shows
devbranch contents git clonewithout-bchecks outdev
This is intentional for the p24-infra ecosystem workflow.
Update CI/CD and local configs after branch rename
After renaming master → main:
GitHub Actions (if any .github/workflows/ files reference master):
$local = "d:\code_2026\<repo>"
Get-ChildItem "$local\.github\workflows" -Filter "*.yml" | ForEach-Object {
(Get-Content $_.FullName -Raw) -replace '\bmaster\b', 'main' | Set-Content $_.FullName
}
git -C $local add .github/workflows/
git -C $local commit -m "ci: update workflow triggers master → main"CLAUDE.md branching section:
Update the branching diagram in CLAUDE.md to show main instead of master.
Affected repos (as of 2026-06-28)
| Repo | Current default | Target default | Scenario |
|---|---|---|---|
| amazon-kdp-tango | master | main | A — rename master→main |
| Art-Agency | main | dev | B — add dev, set as default |
| radekkonarski-personal-brand | main | dev | B — add dev, set as default |
| et-operational-platform | main | dev | B — add dev, set as default |
| p24-infra | main | main (keep) | no change |
| whatsup-android-chat-puller | dev | dev ✅ | no change |
Escalation
If GitHub rejects the default branch change: repo may have branch protection rules on main.
Go to GitHub → Settings → Branches, temporarily disable protection, change default, re-enable.
If team members are surprised by the change: post in the project channel that dev is now the
default merge target. PRs to main will still work but must be created manually with --base main.