Skip to content

[BUG] claude --worktree overwrites the core.hooksPath of $GIT_COMMON_DIR/config #27474

Description

@zzJinux

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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:

  1. If $GIT_DIR/config-core.hooksPath hasn't been specified, it's effectively no-op. Read https://git-scm.com/docs/githooks
  2. 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

  1. Start with any repo with a custom core.hooksPath pointing to anything other than $GIT_DIR/hooks
  2. cd into the repo and execute claude --worktree
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions