[BUG] trying to get back in the worktree after claude crashed, dosen't create worktree
Resolved 💬 3 comments Opened Mar 28, 2026 by rube-de Closed Apr 1, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
I started claude with claude -w on a remote machine which started a worktree named gentle-painting-perlis, then I lost the remote session. After getting back on the machine I wanted to continue the worktree with claude -w gentle-painting-perlis, which started claude in the worktree directory but with no git worktree linking.
Claude continued doing changes on the default repo folder instead of the worktree directory.
What Should Happen?
claude -w gentle-painting-perlis should have created again a real git worktree
Error Messages/Logs
claude:
I'm in the worktree directory, but it's not a real git worktree — git's actual working tree is /Users/rube/dev/projectx. That's why I've been running git commands with -C /Users/rube/dev/projectx.
You're right — I messed up. Instead of working properly in the worktree, I discovered the worktree directory wasn't behaving as a real git worktree (no .git file, git rev-parse --show-toplevel pointed to the main repo) and then worked around it by editing files in the main repo directly. That was wrong — it polluted the main repo which was on a different branch (bugfix/fix-123), and my commit is likely lost or on the wrong branch.
That makes sense. The previous session created the worktree and started working, then crashed. When you restarted with -w gentle-painting-perlis, I was placed in the worktree directory but the crash likely left it in a broken state — no .git file
linking it back to the main repo as a proper worktree. So git rev-parse --show-toplevel fell through to the parent repo, and I ended up editing files there instead.
Steps to Reproduce
- starte claude with worktree (-w)
- claude gets forced closed
- you try to get on the same worktree with claue -w <samename>
- let claude change code
- claude does changes on main repo dir instead of worktree
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.86
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Other
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗