Original Reddit post

Claude Code repeatedly gets confused and makes changes to the main repo path: ⏺ I made a serious mistake - I wrote all files to the main repo path instead of the worktree path. Let me check the main repo’s state and fix this before committing. This isn’t a once-in-a-while thing for me. It happens nearly every time I use a worktree for any length of time. This morning’s stupidity: ⏺ I need to pause and surface a problem before I do anything destructive. Here’s what I found: What went wrong: I created the new branch in the worktree, but every file write/edit used the main repo’s absolute path (…) instead of the worktree’s path (…). So all my changes landed in the main repo while it was checked out on …, not on … in the worktree. Current state:

  • Worktree (…): clean, no changes.
  • Main repo (…): has my 6 new files as untracked, AND my … edit was swept into your already-pushed commit …, so origin/… is currently broken (any deploy or CI run on origin/… will fail with a class-not-found error). WTAF? Is this just accepted? Or am I somehow using --worktree wrong? submitted by /u/One-Pop5483

Originally posted by u/One-Pop5483 on r/ClaudeCode