docs: never merge with --delete-branch - #275
Open
joaodinissf wants to merge 1 commit into
Open
Conversation
joaodinissf
force-pushed
the
docs/no-delete-branch-flag
branch
from
July 30, 2026 19:21
be8c7c3 to
28a2c37
Compare
joaodinissf
force-pushed
the
docs/no-delete-branch-flag
branch
from
July 30, 2026 20:15
28a2c37 to
aa87b8b
Compare
The repository already deletes merged branches, and letting it do so is what preserves stacked pull requests: GitHub retargets any PR based on the merged branch onto its base. Deleting the ref from the client pre-empts that step, and GitHub closes the dependent PR instead — permanently, since a closed PR cannot be reopened while its base is missing and cannot be retargeted while it is closed. This closed #247, which was stacked on #246. Verified in a scratch repository with two identical stacks differing only in the delete method: the flagged one left its dependent PR closed and stranded, the other retargeted cleanly. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
joaodinissf
force-pushed
the
docs/no-delete-branch-flag
branch
from
August 1, 2026 16:39
aa87b8b to
4f6dfa1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
gh pr merge --delete-branchcloses stacked pull requests instead of letting GitHub retarget them.This closed #247, which was based on #246's branch. It has since been recovered — restoring the deleted ref breaks the deadlock, and CLAUDE.md now carries the recipe alongside the rule.
Verified rather than inferred. Two structurally identical stacks in a scratch repository, same settings as here — rebase-merge only,
delete_branch_on_mergeon:--rebase(repo setting deletes the branch)main, still open--rebase --delete-branchThe control stayed retargeted and open throughout the second arm, so it is not a timing artefact.
The mechanism: GitHub's merge flow retargets dependants and then deletes. Deleting from the client pre-empts the retarget step.
Recovery works only in this order — a closed PR cannot be retargeted, and a PR whose base is missing cannot be reopened:
MERGED_HEAD_SHAis the merged PR'shead.sha, which survives the branch deletion. This restores the original PR with its review history and author, which opening a replacement cannot do.This pull request was published with assistance from Claude.