Permission scoping shows main worktree path instead of current worktree path

Resolved 💬 5 comments Opened Feb 24, 2026 by ShonaDouglasKT Closed May 18, 2026

Description

When running Claude Code from a git worktree, the permission prompt always shows the main worktree's path rather than the current worktree's path. For example, when working in /home/user/git/project-devel (a worktree), the prompt says:

"Yes, and don't ask again for similar commands in /home/user/git/project"

...where /home/user/git/project is the main worktree, not the directory the user is actually in.

Root cause

Claude Code appears to resolve the project root via git rev-parse --git-common-dir (or by deriving a parent from --git-dir), which always resolves to the main worktree's .git directory. It then derives the project path from that.

From inside a worktree:

$ git rev-parse --show-toplevel
/home/user/git/project-devel          # ← correct worktree path

$ git rev-parse --git-common-dir
/home/user/git/project/.git           # ← always the main worktree

Expected behaviour

The permission prompt should show the path of the worktree the user is actually working in, not the main worktree path. For example:

"Yes, and don't ask again for similar commands in /home/user/git/project-devel"

Related question

It's also unclear how permissions are actually scoped across worktrees. Since all worktrees share the same --git-common-dir, it appears that permissions granted in any worktree apply to all worktrees of the same repository. This may or may not be intentional, but it should be documented either way.

Environment

  • Claude Code CLI
  • Linux (Debian)
  • Multiple git worktrees of the same repository in sibling directories

View original on GitHub ↗

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