# error: The following untracked working tree files would be overwritten by checkout: file.txt

- **ID:** `git/checkout-conflict-with-untracked-files`
- **Domain:** git
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

Git checkout would overwrite untracked files in the working directory that are present in the target branch but not tracked in the current branch.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 2.38.0 | active | — | — |
| 2.39.0 | active | — | — |
| 2.40.0 | active | — | — |

## Workarounds

1. **Move the conflicting untracked files to a safe location: 'mv file.txt file.txt.backup'. Then checkout the branch. After checkout, you can compare and restore if needed.** (95% success)
   ```
   Move the conflicting untracked files to a safe location: 'mv file.txt file.txt.backup'. Then checkout the branch. After checkout, you can compare and restore if needed.
   ```
2. **Alternatively, stash the untracked files: 'git stash --include-untracked'. Then checkout the branch. Later apply the stash: 'git stash pop'.** (90% success)
   ```
   Alternatively, stash the untracked files: 'git stash --include-untracked'. Then checkout the branch. Later apply the stash: 'git stash pop'.
   ```

## Dead Ends

- **Adding the file to .gitignore and retrying checkout.** — The file is already untracked, so .gitignore won't help; it only prevents future tracking. The checkout still sees the file as a conflict. (90% fail)
- **Using 'git checkout --force' to override the error.** — Force checkout will overwrite the untracked file, potentially losing data. It works but is dangerous. (30% fail)
- **Running 'git clean -fd' to delete all untracked files blindly.** — This deletes all untracked files, not just the conflicting one, which may remove important files. (50% fail)
