Skip to main content

Pruning stale remote branches

Checklist for a repo that's built up years of dead branches. The point is that nothing becomes unrecoverable.

  1. Check nothing references them. Search .github workflows and branch protection rules for branch names before deleting anything.
  2. Confirm what actually deploys. If Actions only deploys main, deleting other branches can't break a deploy.
  3. Archive the refs first. Tag them, so a deleted branch can still be recovered by tag. Do this before any deletion, not after.
  4. Then delete.
  5. Prune worktrees. git worktree list, then remove any whose branch is already merged. These accumulate quietly and hold disk.

Steps 1 to 3 are the ones worth not skipping. Deleting is the easy part.