git
conflict_error
ai_generated
true
冲突(修改/删除):file.txt 在 HEAD 中被删除,但在分支中被修改。分支版本的 file.txt 保留在树中。
CONFLICT (modify/delete): file.txt deleted in HEAD and modified in branch. Version branch of file.txt left in tree.
ID: git/conflict-modify-delete
85%修复率
85%置信度
1证据数
2023-06-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| git 2.30.0 | active | — | — | — |
| git 2.39.0 | active | — | — | — |
| git 2.45.0 | active | — | — | — |
根因分析
合并的一方删除了一个文件,而另一方修改了该文件,导致修改/删除冲突。
English
One side of a merge deleted a file while the other side modified it, causing a modify/delete conflict.
官方文档
https://git-scm.com/docs/git-merge#_how_to_resolve_conflicts解决方案
-
git checkout --ours file.txt && git add file.txt # Keep the deleted side (HEAD), effectively deleting the file
-
git checkout --theirs file.txt && git add file.txt # Keep the modified side (branch), restoring the file with modifications
无效尝试
常见但无效的做法:
-
65% 失败
Running git add on the conflicted file without resolving the conflict will keep the conflict marker in the staged file, leading to build errors or incorrect content.
-
30% 失败
Using git merge --abort when you actually want to keep changes discards all merge progress and requires starting over.