[git] 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. 再提交
$ git commit -m "fix conflict"                                                                                                                          [22:56:33]
[master ac5917d] fix conflict
$ git push                                                                                                                                              [22:57:27]
Counting objects: 46, done.

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

其它解决办法

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

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值