Preflight Checklist
What's Wrong?
claude --worktree overwrites the core.hooksPath of $GIT_COMMON_DIR/config to $GIT_COMMON_DIR/hooks. This ends up as one of the following:
- If
$GIT_DIR/config-core.hooksPath hasn't been specified, it's effectively no-op. Read https://git-scm.com/docs/githooks
- Otherwise, the
core.hooksPath is overwritten, which is destructive (if it points to some non-default path)
I guess that the original intention was to set the hooks for the newly created worktree to the main repo's one. But as I mentioned above, the actual behavior turns out to be merely modifying the $GIT_COMMON_DIR config. If it wants to touch the worktree-specific thing, git config --worktree is the answer (which requires setting another config, though). But even git config --worktree is pointless since, if sharing hooks is the goal, it's already achieved by git-config resolution.
What Should Happen?
core.hooksPath of $GIT_DIR/config must be untouched when Claude Code creates a worktree internally (either by claude --worktree or EnterWorktree tool).
Error Messages/Logs
Steps to Reproduce
- Start with any repo with a custom
core.hooksPath pointing to anything other than $GIT_DIR/hooks
cd into the repo and execute claude --worktree
- Overwritten.
Claude Model
None
Is this a regression?
No, this never worked
Last Working Version
No response
Claude Code Version
2.1.50
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
No response
Preflight Checklist
What's Wrong?
claude --worktreeoverwrites thecore.hooksPathof$GIT_COMMON_DIR/configto$GIT_COMMON_DIR/hooks. This ends up as one of the following:$GIT_DIR/config-core.hooksPathhasn't been specified, it's effectively no-op. Read https://git-scm.com/docs/githookscore.hooksPathis overwritten, which is destructive (if it points to some non-default path)I guess that the original intention was to set the hooks for the newly created worktree to the main repo's one. But as I mentioned above, the actual behavior turns out to be merely modifying the
$GIT_COMMON_DIRconfig. If it wants to touch the worktree-specific thing,git config --worktreeis the answer (which requires setting another config, though). But evengit config --worktreeis pointless since, if sharing hooks is the goal, it's already achieved by git-config resolution.What Should Happen?
core.hooksPathof$GIT_DIR/configmust be untouched when Claude Code creates a worktree internally (either byclaude --worktreeorEnterWorktreetool).Error Messages/Logs
Steps to Reproduce
core.hooksPathpointing to anything other than$GIT_DIR/hookscdinto the repo and executeclaude --worktreeClaude Model
None
Is this a regression?
No, this never worked
Last Working Version
No response
Claude Code Version
2.1.50
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
No response