[FEATURE] Support bare repository setup for worktree handling (`claude --worktree`)
Resolved 💬 7 comments Opened Feb 21, 2026 by zzJinux Closed May 18, 2026
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
The current behavior of claude-code --worktree expects the working directory is a (recursively) subdirectory of a non-bare repository itself or a worktree of such. I strongly believe it's the root cause of #27436 and #27439.
A bare repository with worktrees is a valid setup, if not commonplace. It's reasonable to take it into account as well.
Proposed Solution
- The directory under which worktrees are created should be configurable with an executable path or a shell script, regardless of whether it's bare or non-bare setup.
- If not configured:
- non-bare setup: Defaults to
$GIT_COMMON_DIR/../.claude/worktreesand creates a worktree under it. - bare setup: Fails
- If it's configured
- Execute the configured executable or shell script, providing a relevant context (commit-ish, branch name, session id, etc). The spawned process creates a worktree and prints a JSON object to stdout, specifying either a path to the created worktree or an error reason.
- Respect all Git-specific environment variables related to worktree creation, like
GIT_DIRandGIT_COMMON_DIR(I've verified it already does). - Don't mess with anything else Git-related. I found that the
claude --worktreemodifies$GIT_COMMON_DIR/config. See https://github.com/anthropics/claude-code/issues/27474.
Alternative Solutions
Unable to devise workarounds
Priority
Critical - Blocking my work
Feature Category
CLI commands and flags
Use Case Example
As I described above, having worktrees with a bare repo is completely valid setup.
Additional Context
_No response_
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗