You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: gh stack sync won't adopt an existing local branch #641
gh stack sync fails when a PR has been added to the stack on GitHub (via the web UI) and its head branch already exists locally. Instead of adopting the existing local branch into the local stack, sync aborts:
✗ Cannot pull feature-3 from the remote stack: a local branch with that name already exists
This happens even when the local branch is identical to its remote-tracking branch (0 0 ahead/behind). Because sync aborts at this step, nothing else is synced, so the local stack can't catch up with the remote stack.
Affected command
gh stack sync
gh-stack version
gh stack version 0.3.0
GitHub CLI version
gh version 2.104.0 (2026-11-12)
Operating system
Windows 11
Shell
PowerShell 7
Steps to reproduce
Create a stack locally with gh stack init feature-1 feature-2 and submit it.
Without using gh stack, create feature-3 on top of feature-2, push it, and open a PR based on feature-2.
In the GitHub web UI, add the feature-3 PR to the stack.
Run gh stack sync in the original clone, where feature-3 exists locally and matches origin/feature-3.
Expected behavior
Sync sees that the local feature-3 is the PR's head branch and adopts it into the local stack. It could do that automatically when the local branch matches the remote one or is an ancestor of it, or prompt when they differ. Then it carries on syncing.
Actual behavior
Sync aborts with "a local branch with that name already exists" and the local stack metadata isn't updated.
Workaround: rename the local branch out of the way so sync can recreate it from the remote, then delete the renamed copy:
Activity