[BUG] `claude --worktree` overwrites the `core.hooksPath` of `$GIT_COMMON_DIR/config`
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
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.hooksPathhasn't been specified, it's effectively no-op. Read https://git-scm.com/docs/githooks - Otherwise, the
core.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_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.hooksPathpointing to anything other than$GIT_DIR/hooks cdinto the repo and executeclaude --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_
This issue has 10 comments on GitHub. Read the full discussion on GitHub ↗