Skip to content

Migrate the default branch from master to main #433

Description

@shunk031

Summary

This repository used master as the default branch. We migrated the default branch to main without breaking CI, GitHub Pages, the hosted setup.sh entrypoint, or active pull requests.

Why this mattered

  • The repository default branch was still master.
  • GitHub Pages published from master:/.
  • Several repository-managed references still assumed master.
  • Open pull requests targeted master.
  • We wanted to complete the migration in a controlled order and delete master after verification.

Current known references that were updated

  • README.md
  • .github/workflows/macos.yaml
  • .github/workflows/ubuntu.yaml
  • .github/workflows/test.yaml
  • setup.sh
  • home/dot_local/bin/exact_common/executable_chezmoi-notify-cache
  • tests/install/common/chezmoi_notify_cache.bats

Plan

  • Create main from the current master tip.
  • Open prep PR chore(repo): prepare default-branch migration to main #434 against master that updates repository-managed master references.
  • In the prep PR, temporarily allow both master and main in workflow branch filters so CI still runs before the cutover.
  • Update README.md links from master to main.
  • Update setup.sh so the fallback branch is main.
  • Update the shared chezmoi notify cache helper and its test from origin/master to origin/main.
  • Keep Codecov links branch-agnostic where possible instead of hardcoding branch/main.
  • Merge the prep PR after GitHub Actions checks pass.
  • Fast-forward main to the merged prep commit if needed.
  • Change the repository default branch from master to main.
  • Change GitHub Pages source from master:/ to main:/.
  • Retarget open pull requests #427 and #270 to main.
  • Confirm the repository ruleset still applies to ~DEFAULT_BRANCH.
  • Open cleanup PR chore(ci): drop temporary master cutover support #435 against main to remove temporary dual-branch workflow support.
  • Change workflow filters from dual-branch support back to main only.
  • Change the benchmark auto-push condition to refs/heads/main only.
  • Merge the cleanup PR after required checks pass on main.
  • Delete master after the migration is verified.

Migration guide for existing machines still on master

Run this on each existing machine after main exists remotely and before relying on chezmoi update again.

cd "$(chezmoi source-path)"
git status --short --branch
# If the worktree is dirty, commit or stash changes before continuing.
git fetch origin --prune
git branch -m master main
git branch --set-upstream-to=origin/main main
git remote set-head origin -a
chezmoi update

If git branch -m master main fails because main already exists locally, switch to main, rebind it to origin/main, and then run chezmoi update.

This guide is necessary because chezmoi update uses git pull --autostash --rebase; machines left on local master will break once origin/master is removed.

Acceptance criteria

  • gh repo view reports main as the default branch.
  • GitHub Pages publishes from main:/.
  • Required GitHub Actions checks pass on main.
  • Open pull requests target main.
  • Hosted setup.sh still works after the Pages rebuild.
  • No repository-owned branch/config references still require master.
  • master is deleted after verification.

Notes

  • All Git/GitHub write operations were performed from fresh task-specific worktrees because the source worktree was dirty.
  • bats validation was done through GitHub Actions CI, not locally.
  • Remaining master strings on origin/main are only external upstream URLs or comments, not repository-owned branch/config references.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions