如何使用HEAD和任何mergetool解决所有冲突 [英] How to resolve ALL conflicts using HEAD, with any mergetool

查看:1284
本文介绍了如何使用HEAD和任何mergetool解决所有冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,出于某种原因,我与新的合并修补程序发生了很多冲突。实际[手动]更改的文件没有冲突。
所有的冲突都是在修复过程中未触及的文件,显然它是空白的问题。我将在稍后尝试解决这个问题,但现在我需要合并修补程序和部署。



如何解决所有冲突以使用HEAD版本?我不想按档案去档案。是的,我知道这是一个不好的做法,但冲突都是空白,我知道HEAD是正确的 - 通过所有测试并在生产中正常运行。

有什么想法?



我使用OSX。

解决方案

  git merge -Xours origin / master 

会与<$ c $合并c> origin / master (与 git pull origin master 相同),并通过从本地分支获取版本来解决冲突。

如果你已经通过了糟糕的合并,你可以用 git reset --hard HEAD



在这种情况下,您应该做

  git reset --hard HEAD 
git merge -Xours origin / master

这应该能解决你的问题!



(也值得一提的是, -Xtheirs 会做同样的事情,上游版本在任何冲突。)






此外,最有可能的冲突是因为上游版本使用Windows风格线结局,和任何程序哟你在本地机器上编辑文件时使用的是mac风格或linux风格的行尾。



有些选项可以在git中设置为始终提交windows风格或linux风格的行尾,但总是在工作目录中检出mac-style或linux-style。



更多信息请参阅此链接:
https://help.github.com/articles/dealing-with-line-endings


So for some reason I'm getting a lot of conflicts with a new merged hotfix. The file that was actually [manually] changed has no conflict. All the conflicts are in files that were untouched during the fix and apparently its an issue with whitespaces. I'll try to figure that problem later but now I need to merge the hotfix and deploy.

How can I resolve ALL conflicts to use the HEAD version? I don't want to go file by file. Yes, I know its a bad practice but the conflicts are all whitespaces and I know HEAD is correct — passing all tests and running fine in production.

Any ideas?

I'm using OSX.

解决方案

git merge -Xours origin/master

will do a merge with origin/master (the same thing that git pull origin master does) and will resolve any conflicts by taking the versions from your local branch.

If you're already part-way through the bad merge, you can reset everything to the head first with git reset --hard HEAD.

In that case, you should do

git reset --hard HEAD
git merge -Xours origin/master

And that should fix your problem!

(also worth mentioning, -Xtheirs will do the same thing, but take the upstream version in any conflicts.)


Also, most likely the conflicts are because the upstream version is using windows-style line endings, and whatever program you edited the files in on your local machine is using mac-style or linux-style line endings.

There are options you can set in git to always commit windows-style or linux-style line endings, but always checkout mac-style or linux-style in your working directory.

See this link for more info: https://help.github.com/articles/dealing-with-line-endings

这篇关于如何使用HEAD和任何mergetool解决所有冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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