Repository navigation
feat(worktrees): create a worktree from any ref - #75
Merged
Merged
Conversation
Until now worktrees could only be removed or pruned from the app. A "Worktree" action on local branch, remote branch, PR and log commit rows opens one prefilled dialog; "+ New worktree" in the Worktrees section (now shown even when a repo has none) takes a typed ref with suggestions. The folder defaults to a sibling of the repo, <repo>-<branch>, so the tree stays out of the repo's status and file watcher. A remote branch gets a tracking local branch, a tag or commit is detached unless a branch is named, and a PR is a detached tree that `gh pr checkout` fills in (removed again if gh fails). git's refusals are shown in the dialog rather than forced past; --quiet keeps the progress line from masking them. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Raman Gupta <rocketraman@gmail.com>
rocketraman
force-pushed
the
claude/worktree-creation-ref-260a5d
branch
from
October 27, 2026 21:32
c6525bd to
f5df811
Compare
The dialog called WorktreeOps.defaultPath and pathProblem directly, which the architecture test forbids for the UI package. Both now go through AppState, as the dialog's ref lookups already did. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Raman Gupta <rocketraman@gmail.com>
rocketraman
force-pushed
the
claude/worktree-creation-ref-260a5d
branch
from
October 27, 2026 21:47
ff3f9c6 to
5a378c4
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.
What
Adds a way to create a worktree; previously the app could only remove or prune them.
Worktreehover action on local branch rows, remote branch rows, PR rows and commit rows in the log view, plus+ New worktreein the Worktrees section header. The header now renders for every git repo (as "— none" when there are no worktrees) so the first one can be made.Popup.NewWorktree): prefilled so Enter usually creates. Branch field depends on the source; folder defaults to a sibling<repo>-<branch-slug>(numbered when taken) and follows the branch name until edited; optional "open a terminal there". With no source it asks for a ref, suggests branches/tags, and shows what the text resolves to.WorktreeOps.add):--track -b <name>(editable name, defaults to the short name)--detach, or--no-track -b <name>if a branch is namedgh pr checkout Ninside it; the tree is removed if gh failsresolvetakes a typed ref in git's own order, including the short-name guess when exactly one remote has the branch.Why the sibling default
A worktree inside the checkout shows up as untracked files and sits under the repo's file watcher (the churn
WatchPolicyspecial-cases.claude/worktrees/for). A sibling avoids both.Reviewer notes
--force: refusals (branch held elsewhere, branch name taken, non-empty folder) are shown inline in the dialog, which stays open until git answers.--quietonworktree addis load-bearing: without it git's first stderr line is "Preparing worktree…", whichfirstErrorwould surface instead of the actualfatal:.state.worktreesmay belong to another repo now that the heading renders for repos with no worktrees.Testing
WorktreeCreateTest(11 tests): each source kind, refusals,resolve,refNames,defaultPath,pathProblem. Full suite 248 tests, 0 failures (from the result XML); detekt clean.🤖 Generated with Claude Code