feat: Add worktree commands, per-worktree trunks, and worktree filters#1172
Open
ed-irl wants to merge 1 commit into
Open
feat: Add worktree commands, per-worktree trunks, and worktree filters#1172ed-irl wants to merge 1 commit into
ed-irl wants to merge 1 commit into
Conversation
Collaborator
Author
This was referenced May 19, 2026
Open
da5a5d4 to
7ac5544
Compare
7ac5544 to
da5a5d4
Compare
da5a5d4 to
36bc98e
Compare
93c644e to
512b215
Compare
36bc98e to
c8ef032
Compare
This was referenced Jun 12, 2026
512b215 to
8575070
Compare
c8ef032 to
f44afe8
Compare
8575070 to
b0c48d9
Compare
f44afe8 to
30f5d97
Compare
b0c48d9 to
e3c8701
Compare
30f5d97 to
58442a1
Compare
Worktree.Merge supports --no-ff and optional rerere via per-command -c rerere.enabled=true -c rerere.autoupdate=true flags. On conflict the merge is automatically aborted (default) and a *MergeConflictError carrying the refs and unmerged paths is returned, leaving the worktree at HEAD. Setting MergeOptions.LeaveConflict skips the abort so the caller can drive a conflict-resolution flow. Worktree.IsClean reports whether the worktree has uncommitted changes among tracked files (untracked files are ignored), backed by git status --porcelain --untracked-files=no. Worktree.CheckoutNewBranch creates a new branch at an optional start point in one operation, with a Force flag for git checkout -B semantics.
e3c8701 to
dbeafc0
Compare
58442a1 to
9601c86
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.
Add 'gs worktree create' and 'gs worktree list' commands. By default,
'worktree create' sets up a per-worktree trunk: a local branch (named
after the worktree directory, or set with --trunk) that tracks the same
remote trunk as the main checkout. Stacks created in the worktree are
based on this branch, so 'gs repo sync' and restacks in different
worktrees never contend on a single shared trunk checkout. --no-trunk
keeps the legacy detached-HEAD behavior, and -b/--branch creates a
tracked branch stacked on the new trunk.
The state store gains a per-worktree trunk registry (WorktreeTrunk,
Register/Unregister, TrunkFor, IsTrunk). Trunk checks throughout the
store and branch graph now recognize any registered worktree trunk as a
trunk-equivalent graph root, so traversals stop at it and branches may
be stacked directly on it.
'log short' and 'repo restack' gain -w/--worktree to scope output and
restacking to stacks with a branch checked out in the current worktree,
backed by BranchGraph.StacksInWorktree. 'repo restack' also skips its
trailing checkout. SyncTrunk now distinguishes the canonical remote
trunk from the local trunk it pulls into, fetching the remote ref into
the worktree's own trunk.
Adds Repository.WorktreeAdd for creating worktrees.
Part of #1244