Stop the dev-work merge step from camping on main #307

Merged
nelsong6 merged 1 commit from claude/dev-work-merge-cleanup into main 2026-08-08 16:51:18 -07:00
nelsong6 commented 2026-08-08 16:51:10 -07:00 (Migrated from github.com)

Why

#304 fixed the post-merge instruction — update main as a ref rather than switching a worktree to it. But it left step 3 as "Merge using the repo's normal merge path," which specifies nothing. Agents fill that gap with gh pr merge --squash --delete-branch, and that flag re-creates the exact camping the rest of the doc is trying to prevent.

Observed on #305: the merge succeeded, then gh silently switched the feature worktree onto main.

The mechanism

Both halves of -d are wrong for this repo:

  • Remote half is a no-op. delete_branch_on_merge=true on the repo (verified via gh api), so GitHub deletes the branch before gh asks. The merged branch was already gone.
  • Local half is the camping. Git cannot delete the branch HEAD is on, so gh checks out the default branch and pulls it first. That checkout is the defect, and on success it is silent.

Worth noting because it inverts the previous understanding: freeing main — the #304 fix — does not prevent this. It only converts the loud fatal: 'main' is already used by worktree into a quiet checkout. Not passing the flag is the actual fix.

Changes

  • PR And Merge step 3 — name the command (gh pr merge <n> --squash), forbid -d, give both reasons.
  • Step 4 — note that refs are shared across worktrees, so one git fetch origin main:main updates main everywhere. There is no separate "get main up to date at the git root" task.
  • Step 5 — add the local cleanup the doc previously left undone. It said branches "are auto-deleted," which is true only of the remote; the local branch survived and nothing said to remove it. Now: git checkout --detach main && git branch -D <branch>, which detaches first so nothing camps and lands the worktree on the merged result.
  • Step 6 — optional recipe for refreshing the primary clone's stale working tree without holding the branch.
  • Start section — correct the --delete-branch note, which described only the loud failure mode.

Validation

Docs-only; no build or runtime impact. This PR is being merged with the procedure it documents, which also confirms that a no--d merge performs no local git operations.

## Why #304 fixed the *post-merge* instruction — update `main` as a ref rather than switching a worktree to it. But it left step 3 as "Merge using the repo's normal merge path," which specifies nothing. Agents fill that gap with `gh pr merge --squash --delete-branch`, and that flag re-creates the exact camping the rest of the doc is trying to prevent. Observed on #305: the merge succeeded, then `gh` silently switched the feature worktree onto `main`. ## The mechanism Both halves of `-d` are wrong for this repo: - **Remote half is a no-op.** `delete_branch_on_merge=true` on the repo (verified via `gh api`), so GitHub deletes the branch before `gh` asks. The merged branch was already gone. - **Local half is the camping.** Git cannot delete the branch `HEAD` is on, so `gh` checks out the default branch and pulls it first. That checkout is the defect, and on success it is silent. Worth noting because it inverts the previous understanding: freeing `main` — the #304 fix — does not prevent this. It only converts the loud `fatal: 'main' is already used by worktree` into a quiet checkout. Not passing the flag is the actual fix. ## Changes - **PR And Merge step 3** — name the command (`gh pr merge <n> --squash`), forbid `-d`, give both reasons. - **Step 4** — note that refs are shared across worktrees, so one `git fetch origin main:main` updates `main` everywhere. There is no separate "get main up to date at the git root" task. - **Step 5** — add the local cleanup the doc previously left undone. It said branches "are auto-deleted," which is true only of the remote; the local branch survived and nothing said to remove it. Now: `git checkout --detach main && git branch -D <branch>`, which detaches first so nothing camps and lands the worktree on the merged result. - **Step 6** — optional recipe for refreshing the primary clone's stale working tree without holding the branch. - **Start section** — correct the `--delete-branch` note, which described only the loud failure mode. ## Validation Docs-only; no build or runtime impact. This PR is being merged with the procedure it documents, which also confirms that a no-`-d` merge performs no local git operations.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
romaine-life/spirelens!307
No description provided.