Repository navigation
Description
Describe the bug
Merging a native stack through the asynchronous merge API landed the code on the trunk, then failed partway through. GitHub created one merge commit on the trunk that merges the top PR's head, so every commit in the stack reached the trunk. Then it marked only the two lowest PRs as merged and finished with failed: Could not create merge commit. The other six PRs stayed open even though all their commits were already on the trunk, and there was no supported way to mark them merged afterwards.
Affected command
None. The merge was a direct REST call: PUT /repos/{owner}/{repo}/pulls/{top}/merge-async with merge_method: merge and merge_action: direct_merge. Before that, gh pr merge on the bottom PR was refused with "This pull request is part of a stack and must be merged using the asynchronous merge REST API".
gh-stack version
v0.1.0 installed, but it was not used for the merge.
GitHub CLI version
gh version 2.97.0 (2026-07-31)
Operating system
macOS 26
Shell
zsh
Steps to reproduce
Private organization repository, no merge queue on the trunk, no required reviews, merge commits allowed, "Automatically delete head branches" on.
- Have an 8-PR native stack,
trunk <- #1 <- #2 <- ... <- #8. Each PR was clean and mergeable, its required checks passed on its current head, and every branch contained the branch below it.- Before merging, each branch had been rebased and force-pushed several times, including one rebase of the whole stack onto the latest trunk. Each push used
--force-with-lease.
- Before merging, each branch had been rebased and force-pushed several times, including one rebase of the whole stack onto the latest trunk. Each push used
- Call
PUT /pulls/{#8}/merge-asyncwithshaset to Docs site for stacks #8's head,merge_method: mergeandmerge_action: direct_merge. Response:202,status: pending. - Poll
GET /pulls/{#8}/merge-async/{uuid}.
Expected behavior
Either every PR in the stack is merged and marked merged, or nothing changes, since stack merges are described as atomic.
Actual behavior
- The trunk got one merge commit, "Merge pull request Docs site for stacks #8 from …". Its parents are the previous trunk head and Docs site for stacks #8's head, so all eight PRs' commits are on the trunk, and the trunk's tree is identical to Docs site for stacks #8's head.
- Stacks CLI prototype with core operations #1 and Welcome to GitHub Stacks Discussions! #2 were marked merged, with that same merge commit.
- The async request then ended as
failed: Could not create merge commit. fix: correct ldflags quoting in release workflow #3–Docs site for stacks #8 stayed open, still based on Welcome to GitHub Stacks Discussions! #2–lock state file writes #7's branches. GitHub kept test merges (refs/pull/N/merge) for each of them and reported themMERGEABLE/clean. - Retrying
merge-asyncon Docs site for stacks #8, and then on fix: correct ldflags quoting in release workflow #3 alone, with the matchingshaeach time:202, then the samefailed: Could not create merge commit. Nothing changed. gh pr edit {#3} --base trunkis refused: "Cannot change the base branch because the pull request is part of a stack."- Deleting the head branches of the merged Stacks CLI prototype with core operations #1 and Welcome to GitHub Stacks Discussions! #2 did not retarget fix: correct ldflags quoting in release workflow #3 to the trunk. GitHub closed fix: correct ldflags quoting in release workflow #3 without merging it. Restoring the branch allowed fix: correct ldflags quoting in release workflow #3 to be reopened.
- The only way left was to close fix: correct ldflags quoting in release workflow #3–Docs site for stacks #8 by hand, so they show "Closed" instead of "Merged" and integrations that react to "merged" (for example, issue trackers that close on merge) don't fire.
Possibly related: #457 (open stack PRs when the trunk already has the merge commit), #485 (stale stack base after a partial merge) and #581 (dependent PR left on a merged branch and not retargeted). Here GitHub's own stack merge created the trunk commit and then failed to finish.
Terminal output
$ gh pr merge {#1} --merge --match-head-commit <sha>
GraphQL: This pull request is part of a stack and must be merged using the asynchronous merge REST API. (mergePullRequest)
$ gh api -X PUT repos/{owner}/{repo}/pulls/{#8}/merge-async -f sha=<head sha> -f merge_method=merge -f merge_action=direct_merge
HTTP/2.0 202 Accepted
{"status":"pending","details":{"message":"Merge request enqueued.","merge_method":"merge","merge_action":"direct_merge", ...}}
$ gh api repos/{owner}/{repo}/pulls/{#8}/merge-async/<uuid>
{"status":"failed","details":{"message":"Could not create merge commit", ...}}
$ gh pr edit {#3} --base <trunk>
GraphQL: Cannot change the base branch because the pull request is part of a stack. (updatePullRequest)
The merge request UUIDs and the repository are available to GitHub staff privately on request.
Preflight checks
- I searched the existing issues for duplicates.
- I ran
gh extension upgrade stackand reproduced this issue on the latest stable release. (Not applicable: the merge ran server-side through the REST API, not through the extension.)
Activity