# 无法重写分支：您有未暂存的更改

- **ID:** `git/filter-branch-abort`
- **领域:** git
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 88%

## 根因

尝试在存在未提交更改的工作目录中运行git filter-branch，这些更改可能在历史重写过程中丢失

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| git 2.44.0 | active | — | — |
| git 2.45.0 | active | — | — |
| git 2.46.0 | active | — | — |

## 解决方案

1. ```
   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
   ```

## 无效尝试

- **Running 'git stash' and then filter-branch without popping stash** — Stash is preserved but filter-branch rewrites history; stash may reference old commits (80% 失败率)
- **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% 失败率)
