git报告合并冲突没有变化,空行(使用git-subtree) [英] git reports merge conflict with no changes, empty lines (using git-subtree)

查看:226
本文介绍了git报告合并冲突没有变化,空行(使用git-subtree)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试使用 git-subtree 将库回购合并成更大项目。原则上看起来很好。有时当我做一个git subtree pull时,我会遇到这样的合并冲突:

pre $ lt; ;<< HEAD
=======
从lib repo插入的行
>>>>>>>> 4d348903449ebb584ab224cb34c6038fbf6b352d

这是为了在库回购库中做出的更改,合并到一个尚未本地修改。或者在另一个例子中,我在本地项目库中添加了一行,但是在被合并的子树中包含一个文件:

 <<<<<<< HEAD 
另一个插入行
=======
>>>>>>> 4d348903449ebb584ab224cb34c6038fbf6b352d

为什么git会将这些报告作为合并冲突报告,但报告为区域冲突的区域为空?任何方式来防止它?



这些很容易解决,但它混淆了git子树工作流程

解决方案

这不是解决根源问题的办法,而是缓解它。您可以使用

git merge -Xignore-space-change

来忽略提交中的空间变化。

这可能是您的行结尾的问题。你可以在合并( git merge >没有>)中尝试一个 - 干运行 --dry-run 选项):

$ git merge -Xignore-space-change --no-commit --no-ff $ BRANCH



在实际提交之前查看更改。


I'm testing the use of git-subtree to merge a library repo into a bigger project. It seems great in principle. Sometimes when I do a "git subtree pull" I get merge conflicts like this:

<<<<<<< HEAD
=======
An inserted line from the lib repo
>>>>>>> 4d348903449ebb584ab224cb34c6038fbf6b352d

That's for a change that was made in the library repo, merging into a file that has not been modified locally. Or another example, where I added a line in the local project repo, but in a file that is part of the subtree being merged:

<<<<<<< HEAD
Another inserted line
=======
>>>>>>> 4d348903449ebb584ab224cb34c6038fbf6b352d

Why would git report these as merge conflicts, but the region reported as the conflict is empty? Any way to prevent it?

These are easy enough to resolve, but it messes up the git-subtree workflow

解决方案

It's not a solution to your root problem, but rather a mitigation of it. you can use
git merge -Xignore-space-change to ignore space changes in your commits.

It's probably a problem with your line endings. you can try a --dry-run alternative in merge (git merge does not have --dry-run option):

$git merge -Xignore-space-change --no-commit --no-ff $BRANCH

to see the changes before you actually commit them.

这篇关于git报告合并冲突没有变化,空行(使用git-subtree)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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