问题
提交代码的时候发生冲突.
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.
解决过程
- 先查看状态
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"
可以看到有三个冲突文件.
-
查看文件
image.png
冲突文件已经标明了冲突,直接编辑文件,解决冲突.
-
解决完冲突后, 再尝试
git pull
error: Pulling is not possible because you have unmerged files.
4.不过现在已经能够push了
git status
查看状态
然后使用
git add
将红色状态的文件都添加一下.
- 再提交
$ git commit -m "fix conflict" [22:56:33]
[master ac5917d] fix conflict
$ git push [22:57:27]
Counting objects: 46, done.
其它解决办法
除了直接解决冲突,网上还网到另外一种解决办法
- git stash #将本地修改暂时存储起来
- git pull
- git stash pop #应用最近一次暂存的内容
如果 git stash pop
发生冲突还是一样需要解决冲突
网友评论