Support git worktrees in the branch picker - #11
Open
NetanelDavid wants to merge 2 commits into
Open
Conversation
Worktree branches are now first-class in both the checkout and delete flows instead of appearing as un-actionable "+ branch" entries that git refuses to check out or delete. - Detect worktrees via `git worktree list --porcelain` and map each to its path; keep git's "+" marker in the list display. - Checkout mode: selecting a worktree opens a new shell in that directory (a CLI can't cd its parent shell), cross-platform via $SHELL / ComSpec. Regular branches still `git checkout`. - Delete mode (-d): selecting a worktree runs `git worktree remove` (kept per-item so a dirty/locked one is skipped with a message rather than aborting the batch); regular branches still `git branch -D`. - Fix default selection: the autocomplete prompt matches `default` against a choice value, not an index, so the current branch is now actually preselected. - Docs: README "Worktrees" section + help text; bump to 1.1.0. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Author
|
@idobh2 Please review |
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 & why
Branches checked out in another git worktree currently leak into the list as un-actionable
+ branchentries — git refuses tocheckoutorbranch -Dthem, so picking one just errors. This PR makes worktrees first-class in both flows.Changes
git worktree list --porcelain, mapping each to its path. The list keeps git's+marker so it looks likegit branch.type 'exit' to return). A CLI can'tcdits parent shell, so spawning a shell is the portable equivalent; it uses$SHELL(orComSpec/PowerShell on Windows), so it works across OSes and terminals. Regular branches stillgit checkout.-d) — selecting a worktree runsgit worktree remove(the branch is kept); regular branches stillgit branch -D. Removals run per-item, so a dirty/locked worktree is skipped with a clear message instead of aborting the whole selection.defaultagainst a choice value, not an index, so the current branch is now actually highlighted by default (it never was before).-hhelp; version bumped to1.1.0.No new flags; behavior for existing branch workflows is unchanged.
Screen.Recording.2026-06-24.at.0.46.23.mov
Testing
Verified end-to-end against real worktrees by driving the interactive CLI through a PTY harness:
+and the current branch is preselectedpwdconfirmed) andexitreturns-don a worktree removes it while the branch survives--forcehint), no crash🤖 Generated with Claude Code