# Cannot rewrite branches: You have unstaged changes.

- **ID:** `git/filter-branch-abort`
- **Domain:** git
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 88%

## Root Cause

Attempting to run git filter-branch with uncommitted changes in the working directory, which could be lost during history rewriting.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| git 2.44.0 | active | — | — |
| git 2.45.0 | active | — | — |
| git 2.46.0 | active | — | — |

## Workarounds

1. **Commit or stash changes first: git stash push -m 'temp' && git filter-branch --tree-filter '...' HEAD && git stash pop** (90% success)
   ```
   Commit or stash changes first: git stash push -m 'temp' && git filter-branch --tree-filter '...' HEAD && git stash pop
   ```
2. **Use 'git stash' and then after filter-branch, manually re-apply: git stash && git filter-branch ... && git stash apply --index** (85% success)
   ```
   Use 'git stash' and then after filter-branch, manually re-apply: git stash && git filter-branch ... && git stash apply --index
   ```

## Dead Ends

- **Running 'git stash' and then filter-branch without popping stash** — Stash is preserved but filter-branch rewrites history; stash may reference old commits (80% fail)
- **Using 'git filter-branch -f' to force the operation** — Force flag does not exist for filter-branch; it will still abort with the same error (95% fail)
