合并 Conflict
一句话解释
合并 conflict occurs 当 two 分支更改相同行 的相同 file and Git cannot decide 哪个 version 到 keep.
用大白话说
When merging or rebasing, Git tries to combine changes automatically. If both branches modified the same lines, Git cannot know which version is correct — it reports a merge conflict and pauses, asking you to resolve it manually.
Conflicted files contain markers: <<<<<<< marks the start of the current branch's version, ======= separates the two versions, and >>>>>>> marks the end of the incoming branch's version. You edit the file to keep the correct version, remove the markers, git 添加 the file, and commit.
Conflicts are more likely when branches diverge significantly or multiple people edit the same file. To minimize conflicts: pull frequently, keep branches short-lived, communicate with your team, and consider smaller, more focused files.
示例
<<<<<<< HEAD
const port = 3000;
=======
const port = 8080;
>>>>>>> feature
# Resolve: choose one, remove markers
const port = 8080;Markers show 两者都 versions. 编辑到 keep 正确 one, 移除 markers, 添加, 提交.
相关术语
相关资源
相关课程
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。