# error: Your local changes to the following files would be overwritten by merge: file.txt Please commit your changes or stash them before you merge.

- **ID:** `git/merge-branch-refused-due-to-uncommitted-changes`
- **Domain:** git
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

Uncommitted changes in the working directory conflict with incoming merge changes, and Git refuses to proceed to prevent data loss.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| git 2.28.0 | active | — | — |
| git 2.34.0 | active | — | — |
| git 2.41.0 | active | — | — |

## Workarounds

1. **Stash your changes: git stash push -m 'temp stash', then merge, then apply stash: git stash pop** (90% success)
   ```
   Stash your changes: git stash push -m 'temp stash', then merge, then apply stash: git stash pop
   ```
2. **Commit your changes: git add file.txt && git commit -m 'save local changes', then merge.** (85% success)
   ```
   Commit your changes: git add file.txt && git commit -m 'save local changes', then merge.
   ```
3. **If the changes are not needed, discard them: git checkout -- file.txt, then merge.** (80% success)
   ```
   If the changes are not needed, discard them: git checkout -- file.txt, then merge.
   ```

## Dead Ends

- **** — Permanently discards all local changes, which may be unintended. (60% fail)
- **** — Wipes all uncommitted changes, including those in other files. (70% fail)
- **** — Does not bypass the error; the merge still refuses to proceed. (100% fail)
