美文网首页Git开发专题
[git] fatal: Exiting because of

[git] fatal: Exiting because of

作者: w_w_wei | 来源:发表于2018-07-29 23:34 被阅读0次

问题

提交代码的时候发生冲突.
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.

其它解决办法

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

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

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

相关文章

网友评论

    本文标题:[git] fatal: Exiting because of

    本文链接:https://www.haomeiwen.com/subject/topuyftx.html