Conversation
skarim
added this pull request to stack #530
September 28, 2026 17:20
This branch has not been deployed
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.
Git worktrees share branch refs and objects, but each has its own HEAD, index, working files, and paused Git operations. This PR adds explicit worktree-scoped Git execution: the foundation for independent stacks in separate checkouts and for one stack whose layers live across several worktrees.
Functionality and user impact
Boundary: this PR does not move stack metadata, add navigation flags, or automatically run stack commands in other worktrees. Shared tracking follows in #528, cross-worktree rebase/sync in #529, and distributed modify in #521. Discovery requires Git 2.36+; this supports existing worktrees, not their creation or removal.
Reviewer guide
internal/git/worktree.go:ForWorktreeandgitClientbind execution to a repository/worktree identity. Focus on rejecting a changed Git directory rather than falling back to the caller.internal/git/worktree.go:Worktrees,rebaseBranch, andresolveMainWorktreehandle ownership during detached rebases and separate Git directories. Existingcore.worktreebacklinks are used; unknown checkout paths are not guessed.internal/git/git.go:configureCommand,rebaseArgs, andrunRebaseCommandisolate the environment, set rebase policy, and distinguish a failure to start from a recoverable conflict.internal/git/gitops.go: followRebaseOnto,RebaseContinue, and the conflict/cherry-pick helpers to confirm checkout-sensitive operations stay on the scoped receiver.Related issues
The completed stack closes #459 (tracking survives worktree removal), closes #35 (rebases of branches checked out elsewhere), and closes #87 (sync with a checked-out trunk).
Part 1 of the four-PR split of #520; the next layer is #527.