# 警告：无法合并二进制文件：image.png（HEAD vs. origin/main）

- **ID:** `git/conflict-in-binary-file`
- **领域:** git
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

Git 无法自动合并二进制文件（例如图像、PDF），因为它们没有基于文本的差异，导致冲突需要手动解决。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| git 2.26.0 | active | — | — |
| git 2.33.0 | active | — | — |
| git 2.38.0 | active | — | — |

## 解决方案

1. ```
   Choose one version explicitly: git checkout --ours image.png (keep HEAD version) or git checkout --theirs image.png (keep incoming version), then git add image.png
   ```
2. ```
   If both versions are needed, manually copy the correct version from a backup or regenerate the file, then git add image.png
   ```
3. ```
   Use a dedicated binary merge tool like 'git lfs' or 'git-annex' for large binary files to avoid conflicts in the future.
   ```

## 无效尝试

- **** — Binary files contain non-text data; editing them as text corrupts the file. (95% 失败率)
- **** — Most merge tools cannot display a meaningful diff for binaries; the tool may fail or show nothing useful. (80% 失败率)
- **** — Git still marks the file as conflicted; the merge cannot complete until the conflict is resolved. (100% 失败率)
