解决合并冲突
步骤1 - git merge
git merge
命令下载更改到一个单独的分支,这个分支可被checkout和merge。在merge时Git会尝试自动合并提交。
如果不存在冲突,则合并将“快速进行”,您无需执行任何操作。如果确实存在冲突,则您将检索到错误,并且存储库将处于合并状态。
如下,就表示有冲突:
$ git merge remotes/origin/master
fatal: refusing to merge unrelated histories
$
$ git merge --allow-unrelated-histories remotes/origin/master
Auto-merging staging.txt
CONFLICT (add/add): Merge conflict in staging.txt
Automatic merge failed; fix conflicts and then commit the result.
步骤2 - 查看冲突
git diff
可以查看,要读取格式,本地更改将显示在<<<<<<< HEAD和=