Extend the --delete-branch camping rule to gh pr close #340

Merged
nelsong6 merged 1 commit from claude/delete-branch-flag-on-close into main 2026-10-10 20:19:52 -07:00
nelsong6 commented 2026-10-10 20:18:23 -07:00 (Migrated from github.com)

The doc forbids -d on gh pr merge and explains why, but the camping is the
flag's local half, which is not specific to merge.

Observed on throwaway PR #339: gh pr close 339 --delete-branch, run from the
worktree sitting on that branch, printed
Deleted branch claude/ci-gate-probe and switched to branch main and left the
worktree camping on main exactly as merge -d does.

The remote half is where close differs, so the existing fix does not
transfer. delete_branch_on_merge fires only on a merge, so a closed-unmerged
PR's remote branch survives — confirmed against three closed PRs
(claude/sad-napier-14962f, claude/save-state-on-death-b0ebe8,
codex/keep-camera-in-capture) whose remote branches are all still live. So
"do not pass the flag" would leak the remote branch here, and the cleanup needs
both halves spelled out:

gh pr close <number>
git checkout --detach main
git branch -D <feature-branch>
git push origin --delete <feature-branch>

Docs only — no code paths touched.

The doc forbids `-d` on `gh pr merge` and explains why, but the camping is the flag's **local** half, which is not specific to `merge`. Observed on throwaway PR #339: `gh pr close 339 --delete-branch`, run from the worktree sitting on that branch, printed `Deleted branch claude/ci-gate-probe and switched to branch main` and left the worktree camping on `main` exactly as `merge -d` does. The **remote** half is where `close` differs, so the existing fix does not transfer. `delete_branch_on_merge` fires only on a merge, so a closed-unmerged PR's remote branch survives — confirmed against three closed PRs (`claude/sad-napier-14962f`, `claude/save-state-on-death-b0ebe8`, `codex/keep-camera-in-capture`) whose remote branches are all still live. So "do not pass the flag" would leak the remote branch here, and the cleanup needs both halves spelled out: ``` gh pr close <number> git checkout --detach main git branch -D <feature-branch> git push origin --delete <feature-branch> ``` Docs only — no code paths touched.
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!340
No description provided.