[Bug] Worktree setup modifies main repo git config instead of worktree-specific config

Resolved 💬 3 comments Opened Mar 3, 2026 by daveslutzkin Closed Mar 6, 2026

Bug Description

⏺ Found it. Here's the full story:

Root cause: Claude Code's worktree setup code (a bug in Claude Code itself)

When session 60c120ae created the admin-user-detail-page worktree at 11:14:29, Claude Code's internal worktree setup function ran this logic:

  1. It checks if .husky/ or .git/hooks/ exists in the main repo
  2. Since .git/hooks/ exists (with standard .sample files), it runs:

git config core.hooksPath ~/dev/<repo>/.git/hooks

  1. with cwd set to the worktree path

The bug is that git config in a worktree (without --worktree flag) modifies the main repo's .git/config, not a worktree-specific config. So it wrote hooksPath into your shared config.

The stat timestamp shows 12:22:09 because git push -u at that time (pushing the worktree branch) also wrote to .git/config (adding the branch tracking section on line 23-25), updating the modification time. But the hooksPath line was likely added at 11:14 when the worktree was
created.

Impact: This overrides your global core.hookspath=~/.git-hooks (which has your post-commit and pre-push hooks), pointing instead to .git/hooks/ which only has .sample files — effectively disabling your custom hooks for this repo.

This is a bug in Claude Code v2.1.63's worktree setup — it should use git config --worktree core.hooksPath ... instead of git config core.hooksPath ... so it only affects the worktree's config, not the main repo's. You could report this at
https://github.com/anthropics/claude-code/issues.

Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 2.1.63
  • Feedback ID: ae1da295-871e-458a-916c-adff13972610

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗