Skip to content

feat: wt add goes to the worktree that has the branch - #5

Merged
lorenzolfm merged 1 commit into
mainfrom
add-goes-to-existing-worktree
Sep 4, 2026
Merged

lorenzolfm merged 1 commit into
mainfrom
add-goes-to-existing-worktree

Conversation

@lorenzolfm

Copy link
Copy Markdown
Owner

Summary

  • `wt add ` failed with `fatal: '' is already used by worktree at ...` when a worktree had the branch already.
  • The command now looks for the branch in the worktree list first. When it finds one, it prints that worktree's path, so the shell cds there. This works when the directory name differs from the branch name.
  • README describes the behavior under "Make a worktree".

Test plan

  • `cargo build`, `cargo clippy`, `cargo test` (34 pass)
  • In a scratch bare repo: `wt add feat/x mydir`, then `wt add feat/x` prints `mydir (branch feat/x is here already)` and the path, exit 0

A branch can be in one worktree only. wt add <branch> failed with the
git error when a worktree had the branch already. It now prints the path
of that worktree, so the shell goes there.
@lorenzolfm
lorenzolfm merged commit be102e3 into main Sep 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant