Git and worktrees
Lost commits, hard resets and worktree cleanup gone wrong.
Worktree cleanup deletes a branch with unmerged commits
Ending a Claude Code worktree session removed the worktree and its branch, even when it had commits that were never pushed or merged.
Agent runs git reset --hard and destroys unpushed work
A Claude Code user reported the agent running git reset --hard origin/main on session startup twice, wiping unpushed commits and uncommitted files.