Git pull与章鱼策略产生冲突 [英] Git pull gives conflicts with octopus strategy

查看:680
本文介绍了Git pull与章鱼策略产生冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近当我在主分支中运行 git pull 时,偶尔会出现以下合并错误:

<$ p $尝试简单合并7ff9b5 ...
尝试简单合并6872cd ...
简单合并无效,尝试自动合并。
自动合并file.txt
错误:file.txt中的内容冲突
致命:合并程序失败
自动合并无效。
不应该做八达通。
与策略章鱼合并失败。

然而,在合并尝试之后,有些文件甚至不在master分支中。
我可以使用 git reset 来解决这个问题,然后再次拉动,但是我想知道这个头还是来自哪里,我怎么能找到它?我尝试过查找 gitk 并检查本地GitLab服务器,但找不到任何东西。

解决方案

您应该可以通过 git log< filename> 来查看单个文件的历史记录。这可能有助于识别你的神秘文件。



对于冲突,冲突的来源应与冲突标记一起显示:


$ b $ <<<< HEAD:文件名
...
=======
...
>>>>>>> abcd123:filename

它也可以帮助从 git pull code>工作流程转换为 git fetch 工作流程。

fetch 更新远程分支指针(例如 origin / master ),但不会自动合并本地分支(例如 master )。然后,您可以使用 gitk --all 来直观比较分支, git diff origin / master 以查看终端等等。

一旦你满意并希望合并你的上游改变,你所需要做的就是合并(例如 git merge origin / master 来自 master 分支)。通常, git pull git fetch 后跟 git merge


Lately when I run git pull in my master branch it occasionally gives the following merge error:

   Trying simple merge with 7ff9b5...
   Trying simple merge with 6872cd...
   Simple merge did not work, trying automatic merge.
   Auto-merging file.txt
   ERROR: content conflict in file.txt
   fatal: merge program failed
   Automated merge did not work.
   Should not be doing an Octopus.
   Merge with strategy octopus failed.

However after this merge attempt there are files that aren't even in the master branch. I can fix this issue using git reset and pulling again but I was wondering where this head or commits where coming from how can I find this? I tried looking in gitk and checking the local GitLab servers but I couldn't find anything.

解决方案

You should be able to see an individual file's history with git log <filename>. This may help to identify your mystery files.

For conflicts, the source of the conflict should be shown with the conflict markers:

<<<<<<< HEAD:filename
...
=======
...
>>>>>>> abcd123:filename

It may also help to switch from a git pull workflow to a git fetch workflow.

fetch updates your remote branch pointer (e.g. origin/master) but does not automatically merge your local branch (e.g. master). You can then use gitk --all to visually compare the branches, git diff origin/master to view changes in the terminal, etc.

Once you are satisfied and want to incorporate your upstream changes, all you need to do is merge (e.g. git merge origin/master from the master branch). Generally, git pull is git fetch followed by git merge.

这篇关于Git pull与章鱼策略产生冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆