Feature: Git Worktree Awareness for Claude Code Desktop
Resolved 💬 3 comments Opened May 20, 2026 by Zap1024 Closed May 23, 2026
Problem
Claude Code Desktop sessions operating in git worktrees lack awareness of their current worktree context. This causes Edit/Write tools to resolve absolute paths against the main repository directory, not the current worktree.
Example:
- Worktree path:
D:/repo/.claude/worktrees/feature-branch/ - Main repo path:
D:/repo/ - Session cwd correctly shows worktree
- But Edit/Write resolves
D:/repo/file.md→ main directory, not worktree
Impact
- AI agents in worktree sessions accidentally modify main branch files
- Changes appear "staged" on main but are actually 0-byte placeholder files
- Worktree isolation guarantee is violated
Expected Behavior
Claude Code should:
- Detect when session is inside a git worktree
- Use worktree's root as the base for all file operations
- Optionally respect a
git.worktreeStrategysetting insettings.json
Proposed Solution
Add a git.worktreeStrategy option to settings.json:
{
"git": {
"worktreeStrategy": "current-branch"
}
}
Behavior options:
"current-branch"(recommended): Edit operations target current worktree"main-only": Edit operations always target main repository"prompt": Prompt user when path ambiguity detected
Environment
- Claude Code Desktop
- Windows 10/11
- Git worktrees
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗