Repository navigation
Description
Describe the bug
After the bottom PRs of a stack were squash-merged, the next branch (C) was updated on the remote to sit on the squash-merge commit and the local branch was reset to the remote. The base recorded for C in .git/gh-stack was not updated and still pointed at an old tip of the merged parent B, which C no longer contains.
gh stack sync then cannot find a usable previous base for C, so it aborts before pushing anything:
- The recorded base fails
rebaseBoundaryContainsbecauseCno longer contains it. - The fallback,
git merge-base --fork-point master C, also fails because localmasterwas fast-forwarded past the squash-merge commit and never pointed at it, so the commit isn't inmaster's reflog.
The branch itself is healthy. git merge-base C origin/master returns the squash-merge commit, which is the correct cutoff. Setting base in .git/gh-stack to that commit by hand makes gh stack sync rebase and push the whole stack correctly.
This happens for us every time a bottom PR merges. The error matches #571, but the cause is different: no local rebase or worktree mix-up is involved.
Affected command
gh stack sync
gh-stack version
gh stack version 0.3.0
GitHub CLI version
gh version 2.105.0 (2026-11-17)
Operating system
macOS 26.6.2
Shell
zsh
Steps to reproduce
- Create a stack
master <- A <- B <- C <- D …withgh stackand submit it. - Squash-merge PRs
AandBon GitHub.Bmerges as commitM. - On the remote,
Cis force-updated to sit onM. Locally this showed up as afetch … forced-updateoforigin/C, not as a push from this clone. We assume GitHub's stack feature rebased it, but we haven't confirmed that. - Local
Cis reset toorigin/C(reflog:branch: Reset to origin/C)..git/gh-stackstill listsC'sbaseas an oldBtip that is not an ancestor ofC. - Locally
masterfast-forwards from a commit beforeMto a commit after it, soMnever appears inmaster's reflog. - Commit something on
Cand rungh stack sync.
Expected behavior
gh stack sync sees that C already sits on trunk past the merged PRs. It uses git merge-base C <trunk> (or the merged PR's merge commit) as the previous base, rebases C onto the current trunk, cascades upstack, and pushes.
Two ways to fix it:
- When the parent PR is known to be merged, also accept the merged PR's merge commit as a boundary if
Ccontains it. - When
Cis reset to its remote, update its recordedbasetoo.
Actual behavior
Sync skips the merged branches, then aborts without rebasing or pushing any branch.
Terminal output
✓ Fetched latest master from origin
✓ Trunk master is already up to date
Rebasing stack ...
✓ Skipping A (PR #… merged)
✓ Skipping B (PR #… merged)
✗ could not determine the previous base of C after master changed; rebase this branch manually
Repro state just before the failing sync:
$ git merge-base --is-ancestor <recorded base of C> C # false
$ git merge-base C origin/master # M (squash-merge commit of B's PR)
$ git reflog show master | grep <M> # no match
Workaround: set C's "base" in .git/gh-stack to git merge-base C origin/master, then run gh stack sync. Sync then rebased and pushed all 15 open branches with no merged commits replayed.
Preflight checks
- I searched the existing issues for duplicates.
- I ran
gh extension upgrade stackand reproduced this issue on the latest stable release.
Activity