当前位置:   article > 正文

[git] fatal: Exiting because of an unresolved conflict.

fatal: exiting because of an unresolved conflict.

问题

提交代码的时候发生冲突.
git push

hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

git pull

error: Pulling is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.

解决过程

  1. 先查看状态
    git status

You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)

Unmerged paths:
(use "git add <file>..." to mark resolution)

both modified: "\346\226\207\346\241\243/About Project.md"
both added: "\346\226\207\346\241\243/web.md"
both added: "\346\226\207\346\241\243/\344\273\273\345\212\241.md"

可以看到有三个冲突文件.

  1. 查看文件

    image.png

     

    冲突文件已经标明了冲突,直接编辑文件,解决冲突.

  2. 解决完冲突后, 再尝试
    git pull

error: Pulling is not possible because you have unmerged files.

4.不过现在已经能够push了
git status 查看状态

image.png
然后使用 git add将红色状态的文件都添加一下.

  1. 再提交
  1. $ git commit -m "fix conflict" [22:56:33]
  2. [master ac5917d] fix conflict
  3. $ git push [22:57:27]
  4. Counting objects: 46, done.

注意:如果还不行的话,就使用idea的update project操作的merge方法

其它解决办法

除了直接解决冲突,网上还网到另外一种解决办法

  1. git stash #将本地修改暂时存储起来
  2. git pull
  3. git stash pop #应用最近一次暂存的内容

如果 git stash pop发生冲突还是一样需要解决冲突

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/638359
推荐阅读
相关标签
  

闽ICP备14008679号