git 遇到冲突CONFLICT (content): Merge conflict in index.html Automatic merge failed; fix conflicts and then commit the result.如何解决-完整说明和操作-优雅草央千澈

当遭遇冲突我们会发现会有提示是哪个文件造成冲突,Merge conflict in index.html Automatic merge failed; fix conflicts and then commit the result. 提示就是index.html造成了 冲突,一般来说造成这个问题是由于之前未提交的内容,导致线上分支和本地分支有区别,在这种情况下没有git pull 先行拉取

hint: Updates were rejected because the remote contains work that you do not
hint: have locally. This is usually caused by another repository pushing to
hint: the same ref. If you want to integrate the remote changes, use
hint: 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

因此在这个问题之前一般伴随这样的问题,提示在git push前 先拉取 git pull,因此你一拉取直接报错

那么我们就打开这个文件

git 遇到冲突CONFLICT (content): Merge conflict in index.html Automatic merge failed; fix conflicts and t_git

我们会发现和线上分支有区别的部分 会这样提示,我们手动来解决 删掉

<<<<<<< HEAD
=======
>>>>>>>

这些内容

git 遇到冲突CONFLICT (content): Merge conflict in index.html Automatic merge failed; fix conflicts and t_git_02

这时候我们再来 git add index.html 将解决后的文件添加到暂存区

git add +修改的文件名

接下来 继续 git commit -m ‘解决冲突’

git push

不再报错!完美解决!

git 遇到冲突CONFLICT (content): Merge conflict in index.html Automatic merge failed; fix conflicts and t_git_03