claude-code - 💡(How to fix) Fix [BUG] Claude code used full path bypassing worktree edits [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#55044Fetched 2026-05-01 05:47:42
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×4commented ×1

Error Message

Error Messages/Logs

Root Cause

The branch is there. I cannot switch to the worktree or the branch because it is actively used by claude code.

Code Example

➜ git worktree list
/<path>/<project>                                           9924f5f [main]
/<path>/<project>/.claude/worktrees/noble-soaring-elephant  9924f5f [worktree-noble-soaring-elephant]

---
RAW_BUFFERClick to expand / collapse

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?

I am using claude code inside a worktree using claude --worktree. The worktree is created:

➜ git worktree list
/<path>/<project>                                           9924f5f [main]
/<path>/<project>/.claude/worktrees/noble-soaring-elephant  9924f5f [worktree-noble-soaring-elephant]

The branch is there. I cannot switch to the worktree or the branch because it is actively used by claude code.

The agent was asked to do an action. The main branch was updated. I am not going to ask an LLM why it did something. It does not know. I did try and it hallucinated how worktrees work. The behavior was incorrect however the tools/subagents were called to a full path of my repo. The edits should be within the isolation of the worktree I opened the harness in. I now have to untie the agents vomit from my work.

From what I can tell the agent used a full path to the directory for the subagent calls. The full path was to the root of the project not the relative path of the agent's worktree.

What Should Happen?

When in a worktree claude code should use either the absolute path to the worktree it is in or a relative path.

Error Messages/Logs

Steps to Reproduce

It is hit or miss behavior. Run claude --worktree ask for an edit and hope it does not stomp on main.

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.123

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Windows Terminal

Additional Information

No response

extent analysis

TL;DR

The issue can be fixed by ensuring Claude Code uses the correct path, either absolute or relative, within the worktree.

Guidance

  • Verify that the claude --worktree command is correctly configured to use the worktree's path instead of the main project path.
  • Check the documentation for claude --worktree to see if there are any options or settings that control the path used for subagent calls.
  • Test the behavior with a simple edit action to see if the issue is consistent and reproducible.
  • Consider filing a bug report with more detailed steps to reproduce, as the current steps are described as "hit or miss".

Notes

The issue seems to be related to the way Claude Code handles paths within a worktree, and the fact that it's a regression suggests that a previous version worked correctly. However, without more information about the previous working version, it's difficult to provide a more specific fix.

Recommendation

Apply workaround: Use the --worktree option with the correct path to ensure Claude Code uses the worktree's path, until a fixed version is available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Claude code used full path bypassing worktree edits [1 comments, 2 participants]