claude-code - 💡(How to fix) Fix [Bug] Tracked files lost local changes after `git checkout -- .` and untracked files deleted after `git clean -fd` [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#46962Fetched 2026-04-13 05:45:11
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
labeled ×5

Error Message

[{"error":"Error: ENOENT: no such file or directory, unlink 'C:\Users\yossi\AppData\Local\Temp\claude\C--Users-yossi-PycharmProjects-PythonProject2\8b06513c-bb53-42c0-89b7-4f6985686345\tasks\a0701036a2bbd6c95.output'\n at async <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:7823:299)","timestamp":"2026-04-12T09:21:58.798Z"},{"error":"MaxFileReadTokenExceededError: File content (13194 tokens) exceeds maximum allowed tokens (10000). Use offset and limit parameters to read specific portions of the file, or search for specific content instead of reading the whole file.\n at KO_ (B:/~BUN/root/src/entrypoints/cli.js:4500:12874)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-04-12T09:22:01.034Z"},{"error":"Error: ENOENT: no such file or directory, unlink 'C:\Users\yossi\AppData\Local\Temp\claude\C--Users-yossi-PycharmProjects-PythonProject2\8b06513c-bb53-42c0-89b7-4f6985686345\tasks\aa2016c19b09672af.output'\n at async <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:7823:299)","timestamp":"2026-04-12T09:22:06.872Z"},{"error":"MaxFileReadTokenExceededError: File content (15896 tokens) exceeds maximum allowed tokens (10000). Use offset and limit parameters to read specific portions of the file, or search for specific content instead of reading the whole file.\n at KO_ (B:/~BUN/root/src/entrypoints/cli.js:4500:12874)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-04-12T09:22:08.910Z"},{"error":"MaxFileReadTokenExceededError: File content (17411 tokens) exceeds maximum allowed tokens (10000). Use offset and limit parameters to read specific portions of the file, or search for specific content instead of reading the whole file.\n at KO_ (B:/~BUN/root/src/entrypoints/cli.js:4500:12874)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-04-12T09:22:08.923Z"},{"error":"Error: ENOENT: no such file or directory, unlink 'C:\Users\yossi\AppData\Local\Temp\claude\C--Users-yossi-PycharmProjects-PythonProject2\8b06513c-bb53-42c0-89b7-4f6985686345\tasks\a63247750a14a7047.output'\n at async <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:7823:299)","timestamp":"2026-04-12T09:39:27.850Z"}]

Code Example

[{"error":"Error: ENOENT: no such file or directory, unlink 'C:\\Users\\yossi\\AppData\\Local\\Temp\\claude\\C--Users-yossi-PycharmProjects-PythonProject2\\8b06513c-bb53-42c0-89b7-4f6985686345\\tasks\\a0701036a2bbd6c95.output'\n    at async <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:7823:299)","timestamp":"2026-04-12T09:21:58.798Z"},{"error":"MaxFileReadTokenExceededError: File content (13194 tokens) exceeds maximum allowed tokens (10000). Use offset and limit parameters to read specific portions of the file, or search for specific content instead of reading the whole file.\n    at KO_ (B:/~BUN/root/src/entrypoints/cli.js:4500:12874)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-12T09:22:01.034Z"},{"error":"Error: ENOENT: no such file or directory, unlink 'C:\\Users\\yossi\\AppData\\Local\\Temp\\claude\\C--Users-yossi-PycharmProjects-PythonProject2\\8b06513c-bb53-42c0-89b7-4f6985686345\\tasks\\aa2016c19b09672af.output'\n    at async <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:7823:299)","timestamp":"2026-04-12T09:22:06.872Z"},{"error":"MaxFileReadTokenExceededError: File content (15896 tokens) exceeds maximum allowed tokens (10000). Use offset and limit parameters to read specific portions of the file, or search for specific content instead of reading the whole file.\n    at KO_ (B:/~BUN/root/src/entrypoints/cli.js:4500:12874)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-12T09:22:08.910Z"},{"error":"MaxFileReadTokenExceededError: File content (17411 tokens) exceeds maximum allowed tokens (10000). Use offset and limit parameters to read specific portions of the file, or search for specific content instead of reading the whole file.\n    at KO_ (B:/~BUN/root/src/entrypoints/cli.js:4500:12874)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-12T09:22:08.923Z"},{"error":"Error: ENOENT: no such file or directory, unlink 'C:\\Users\\yossi\\AppData\\Local\\Temp\\claude\\C--Users-yossi-PycharmProjects-PythonProject2\\8b06513c-bb53-42c0-89b7-4f6985686345\\tasks\\a63247750a14a7047.output'\n    at async <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:7823:299)","timestamp":"2026-04-12T09:39:27.850Z"}]
RAW_BUFFERClick to expand / collapse

Bug Description משת הקבצים ה־tracked איבדו את השינויים המקומיים שלהם בגלל git checkout -- . stage_visual_diagnostics.py ושאר קבצי הלוגים ה־untracked נמחקו בגלל git clean -fd

Environment Info

  • Platform: win32
  • Terminal: windows-terminal
  • Version: 2.1.101
  • Feedback ID: 7d7fb44b-502d-4d5b-8fe5-010c4764bade

Errors

[{"error":"Error: ENOENT: no such file or directory, unlink 'C:\\Users\\yossi\\AppData\\Local\\Temp\\claude\\C--Users-yossi-PycharmProjects-PythonProject2\\8b06513c-bb53-42c0-89b7-4f6985686345\\tasks\\a0701036a2bbd6c95.output'\n    at async <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:7823:299)","timestamp":"2026-04-12T09:21:58.798Z"},{"error":"MaxFileReadTokenExceededError: File content (13194 tokens) exceeds maximum allowed tokens (10000). Use offset and limit parameters to read specific portions of the file, or search for specific content instead of reading the whole file.\n    at KO_ (B:/~BUN/root/src/entrypoints/cli.js:4500:12874)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-12T09:22:01.034Z"},{"error":"Error: ENOENT: no such file or directory, unlink 'C:\\Users\\yossi\\AppData\\Local\\Temp\\claude\\C--Users-yossi-PycharmProjects-PythonProject2\\8b06513c-bb53-42c0-89b7-4f6985686345\\tasks\\aa2016c19b09672af.output'\n    at async <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:7823:299)","timestamp":"2026-04-12T09:22:06.872Z"},{"error":"MaxFileReadTokenExceededError: File content (15896 tokens) exceeds maximum allowed tokens (10000). Use offset and limit parameters to read specific portions of the file, or search for specific content instead of reading the whole file.\n    at KO_ (B:/~BUN/root/src/entrypoints/cli.js:4500:12874)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-12T09:22:08.910Z"},{"error":"MaxFileReadTokenExceededError: File content (17411 tokens) exceeds maximum allowed tokens (10000). Use offset and limit parameters to read specific portions of the file, or search for specific content instead of reading the whole file.\n    at KO_ (B:/~BUN/root/src/entrypoints/cli.js:4500:12874)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-12T09:22:08.923Z"},{"error":"Error: ENOENT: no such file or directory, unlink 'C:\\Users\\yossi\\AppData\\Local\\Temp\\claude\\C--Users-yossi-PycharmProjects-PythonProject2\\8b06513c-bb53-42c0-89b7-4f6985686345\\tasks\\a63247750a14a7047.output'\n    at async <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:7823:299)","timestamp":"2026-04-12T09:39:27.850Z"}]

extent analysis

TL;DR

To avoid losing local changes, use git checkout with caution and consider using git checkout --patch or git stash to preserve changes before switching branches.

Guidance

  • Be cautious when using git checkout -- as it can discard local changes; instead, use git checkout --patch to selectively discard changes.
  • Use git stash to temporarily save local changes before switching branches, allowing for easy recovery later.
  • Avoid using git clean -fd without verifying the files to be deleted, as it can permanently remove untracked files.
  • Consider configuring Git to prompt before discarding local changes or deleting untracked files.

Example

# Stash local changes before switching branches
git stash

# Switch branches
git checkout other-branch

# Recover stashed changes
git stash apply

Notes

The provided error messages indicate issues with file handling and token limits, but the primary concern is the loss of local changes due to git checkout -- and git clean -fd. The suggested guidance focuses on mitigating these specific issues.

Recommendation

Apply workaround: Use git stash and git checkout --patch to preserve local changes and avoid accidental discarding of modifications. This approach allows for more control over changes and reduces the risk of losing important work.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING