当前位置:   article > 正文

Git 出错error: Pulling is not possible because you have unmerged files_$ git pull origin master error: pulling is not pos

$ git pull origin master error: pulling is not possible because you have unm

参考:https://blog.csdn.net/zxsted/article/details/17022665
在git pull的过程中,如果有冲突,那么除了冲突的文件之外,其它的文件都会做为staged区的文件保存起来。

重现:

$ git pull origin master

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
  • 2
  • 3
  • 4

通过git status你会发现下面古怪的事情:

$ git status 
On branch master
Your branch and 'origin/master' have diverged,
and have 1 and 7 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

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

Changes to be committed:

	modified:   CMakeLists.txt
	modified:   builtin_op_importers.cpp

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

	both modified:   plugin_op/onnx_plugin/PRelu_Plugin.cu

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	debug/
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

本地的push和merge会形成MERGE-HEAD(FETCH-HEAD), HEAD(PUSH-HEAD)这样的引用。HEAD代表本地最近成功push后形成的引用。MERGE-HEAD表示成功pull后形成的引用。可以通过MERGE-HEAD或者HEAD来实现类型与svn revet的效果。

解决:

1.将本地的冲突文件冲掉,不仅需要reset到MERGE-HEAD或者HEAD,还需要–hard。没有后面的hard,不会冲掉本地工作区。只会冲掉stage区。

git reset --hard FETCH_HEAD

2.git pull就会成功。

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

闽ICP备14008679号