Repository navigation
Submit a stack from whichever worktree has it checked out - #50
Merged
DomBlack merged 1 commit intoOct 16, 2026
Merged
Conversation
DomBlack
added this pull request to stack #51
October 16, 2026 12:17
gh stack only reads the stack file in the git dir it runs in, so a stack started in the main checkout couldn't be submitted (or added to) from a worktree that had its branch checked out: gh stack said the branch wasn't in a stack. The same went for stacks an older git-stack had already put in the main checkout's file from a worktree, like the one I hit with init. So before running gh stack submit or add, we now find the file holding the current branch's stack and, if it isn't this worktree's, move that stack's record over as it is (PR records, ids and anything else in it included). Check the branch out somewhere else and submit from there and it moves again. Nothing is read from git unless some stack actually lives in another worktree's file, so the usual case costs nothing extra.
DomBlack
force-pushed
the
dom/adopt-stack-into-worktree
branch
from
October 16, 2026 12:18
a42b2d6 to
60c8414
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.
Fixing where new stacks get written (the PR below) doesn't help a stack that's already in another worktree's file. A stack started in the main checkout and then checked out in a worktree still can't be submitted or added to from there, and neither can the ones an older git-stack already put in the wrong file.
So before running gh stack submit or add, we find the file holding the current branch's stack and, if it isn't this worktree's, move that stack's record over as it is (PR records, the stack id and anything we don't model all come along). Check the branch out somewhere else and submit there and it just moves again.
We only ask git for the current branch when some stack actually lives in another worktree's file, so the usual case doesn't do any extra work.