Repository navigation
fix(shell): go to the worktree holding a branch instead of taking it - #55
Merged
Merged
Conversation
`git checkout <branch>` switched the main checkout to a branch even when another worktree had it checked out, detaching that worktree. A branch open in a worktree usually means work is happening there, so this moved people's checkouts out from under them. Now it cds into that worktree and detaches nothing; free branches still switch the main checkout. `-.` (this worktree) remains the explicit way to take a branch, still only from a worktree with no uncommitted changes to tracked files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 checkout <branch>(andgco/gsw) switched the main checkout to the branch even when another worktree had it checked out, detaching that worktree to free it. A branch open in a worktree usually means someone, often a Claude session, is working there. So this moved checkouts out from under people: in practice, a branch you meant to visit ended up in the main repo, with its worktree left detached.Now a branch held by another worktree takes you into that worktree, and nothing is detached. Free branches still switch the main checkout, and the current worktree's own branch still stays put.
-.("this worktree") is still the explicit way to take a branch from another worktree, as before: only when that worktree has no uncommitted changes to tracked files, and reattached if the switch fails._git_switch_in. It reads the caller'shere(set by-.ingit()) through zsh's dynamic scoping, likewtandtop.-.take with clean, untracked-only and dirty holders, reattach after a failed switch, PRs with and without-., plus the earlier free-branch, remote-only, PR and passthrough cases.git worktree pathhelper and the PR resolution logic are unchanged.🤖 Generated with Claude Code