Claude Code

Claude Code Could Delete Your Worktree at Exit: How to Update and Recover Commits

Before 2.1.304, quitting a claude --worktree session could remove the worktree and its branch without asking. The update command, how to check your version, and how to get commits back with git

2min read
1prompts to copy
6numbered steps
5sections

If you run Claude Code with the --worktree flag, older versions could delete the worktree and its branch when you quit, without asking, when HEAD was detached or on another branch. Commits in it could be lost. Version 2.1.304 fixed it.

Here's the update command, how to check your version, and how to recover commits with git.

Free, for your email

Get the full setup steps + the copy-paste setup prompt

The rest of this guide (5 more sections, 1 copy-paste prompt) opens right here. The setup prompt, one paste into Claude that sets it all up, comes by email only. Use your real address.

50,000+ follow where these guides come from. No spam, unsubscribe in one click.

Read next