Skip to content

Comments

Improve worktree error when branch already checked out#59

Merged
javoire merged 1 commit intomainfrom
worktreehelp
Feb 3, 2026
Merged

Improve worktree error when branch already checked out#59
javoire merged 1 commit intomainfrom
worktreehelp

Conversation

@javoire
Copy link
Owner

@javoire javoire commented Feb 2, 2026

Summary

  • Parse git's "is already used by worktree at" error to extract the existing worktree path
  • Show helpful suggestions: navigate to existing worktree (cd <path>) or remove it (git worktree remove <path>)
  • Also fixes a linter warning by using strings.CutPrefix instead of HasPrefix + TrimPrefix

🤖 Generated with Claude Code

When running `stack worktree <branch>` for a branch that's already
checked out in another worktree, show helpful suggestions to navigate
to or remove the existing worktree instead of a raw git error.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@javoire javoire merged commit 72e6887 into main Feb 3, 2026
1 check passed
@javoire javoire deleted the worktreehelp branch February 3, 2026 14:49
javoire pushed a commit that referenced this pull request Feb 3, 2026
…026-02-03)

### Features

* improve error message when branch already checked out in worktree ([#59](#59)) ([72e6887](72e6887))
* symlink .env file into worktrees ([#60](#60)) ([bd64571](bd64571))
@javoire
Copy link
Owner Author

javoire commented Feb 3, 2026

🎉 This PR is included in version 1.14.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant