主页
主页

git 冲突报错:Pull is not possible because you have unmerged files

一般的git流程:

1.git add .

2.git commit -m ‘test’

3.git pull

4.git push

当在服务器上改动文件后,再次git pull则会发生冲突,由于本地和服务器的文件不一致导致的冲突

1
2
3
4
5
Unmerged paths:
(use "git add/rm <file>..." as appropriate to mark resolution)

both modified: Gemfile.lock
both modified: config/initializers/0_redis.rb

如何解决呢?

方法1.重置到合并之前,也就是最近一次提交没有冲突时候,然后再git pull

git reset -hard HEAD

方法2.找到冲突的文件【Gemfile.lock,0_redis.rb】,手动删除其中,再git pull

1
2
3
4
5
<<<<<<< HEAD
自己写的代码
=======
别人写的代码
>>>>>>> xxxxxxxxxxxxxxxxxxxxxxx

自己写的代码即可.

相关命令:

git reflog #查看commit ,id

git branch d chen #删除chen分支

复杂情况可参考:

git 高级教程

支持一下
扫一扫,支持chen
  • 微信扫一扫
  • 支付宝扫一扫