File search tools default to wrong directory when using git worktree
Resolved 💬 2 comments Opened Mar 1, 2026 by maplezzk Closed Mar 1, 2026
Description
When using Claude Code with a git worktree, the working directory is correctly set to the worktree path (e.g., .claude/worktrees/branch-name), but file search tools (Glob, Grep, Read) default to searching the main repository directory instead of the worktree directory.
Steps to Reproduce
- Create a git worktree:
git worktree add .claude/worktrees/feature-branch - Set the working directory to the worktree in Claude Code settings
- Use Glob or Grep to search for a file - it searches the main repo, not the worktree
- Edit a file using Read/Edit - it modifies the main repo file, not the worktree
Expected Behavior
File search tools should respect the worktree working directory setting.
Environment
- Claude Code version: Latest
- OS: macOS
- Shell: zsh
Workaround
Must use absolute paths to worktree files to avoid modifying the main repository.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗