# 错误：分支 'feature-x' 未完全合并。如果您确定要删除它，请运行 'git branch -D feature-x'。

- **ID:** `git/error-branch-not-fully-merged`
- **领域:** git
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 95%

## 根因

尝试使用 git branch -d 删除一个分支，该分支包含从当前 HEAD 或其上游无法到达的提交，表明可能会丢失工作。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| git 1.7.0 | active | — | — |
| git 2.30.0 | active | — | — |
| git 2.45.0 | active | — | — |

## 解决方案

1. ```
   git branch -D feature-x  # Force delete the branch if you are certain its work is no longer needed
   ```
2. ```
   git checkout feature-x && git log --oneline --not --remotes=origin  # Review unmerged commits, then merge or cherry-pick them to main before safe deletion with git branch -d
   ```

## 无效尝试

- **** — Running git merge --squash on the branch before deleting does not actually merge the commits; it only creates a squash commit that doesn't preserve history, so the branch still appears unmerged. (70% 失败率)
- **** — Using git branch -d after a git rebase that rewrites history may still fail because the original commits are no longer directly referenced, even if they are functionally merged. (50% 失败率)
