[BUG] Claude Code executed `git checkout` and destroyed uncommitted work without user confirmation

Resolved 💬 3 comments Opened May 27, 2026 by hachikou Closed Jun 28, 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?

Title: Claude Code executed git checkout and destroyed uncommitted work without user confirmation

Summary:
Claude Code ran git checkout on a source file without asking for explicit user confirmation, permanently destroying uncommitted source code changes that were in progress.

What happened:

  1. The user instructed Claude Code to fix incorrect line endings in a source file.
  2. While attempting to fix the issue, Claude Code executed git checkout on that file without asking for confirmation.
  3. This operation erased all uncommitted changes in the file — including a copy constructor (several dozen lines of code) that Claude Code itself had added earlier in the same session.
  4. The user happened to have a backup and was able to manually restore the work; without that backup, the changes would have been unrecoverable.

Expected behavior:
Before executing git checkout on a file with uncommitted changes — an irreversible operation that permanently discards those changes — Claude Code should ask for explicit user confirmation.

Actual behavior:
Claude Code executed git checkout without asking for confirmation, silently destroying the user's uncommitted work.

Additional context:
The user consistently asks Claude Code for confirmation before any write or overwrite operation during their sessions. Claude Code is therefore well aware of this expectation, making the silent execution of this destructive operation all the more unacceptable.

Impact:
All in-progress source code changes in the file were lost. Recovery was only possible because the user had manually created a backup beforehand.

Contradiction with system guidelines:
Claude Code's own system prompt explicitly lists "overwriting uncommitted changes" as a destructive operation that warrants user confirmation before proceeding. Despite this, the operation was carried out without any confirmation prompt.

What Should Happen?

Expected behavior:
Before executing git checkout on a file with uncommitted changes — an irreversible operation that permanently discards those changes — Claude Code should ask for explicit user confirmation.

Error Messages/Logs

Steps to Reproduce

N/A

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.152

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗