简体   繁体   English

git报告合并冲突没有变化,空行(使用git-subtree)

[英]git reports merge conflict with no changes, empty lines (using git-subtree)

I'm testing the use of git-subtree to merge a library repo into a bigger project. 我正在测试使用git-subtree将库repo合并到一个更大的项目中。 It seems great in principle. 原则上似乎很棒。 Sometimes when I do a "git subtree pull" I get merge conflicts like this: 有时当我做一个“git subree pull”时,我得到这样的合并冲突:

<<<<<<< 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? 为什么git会将这些报告为合并冲突,但该地区报告称冲突是空的? Any way to prevent it? 有什么方法可以预防吗?

These are easy enough to resolve, but it messes up the git-subtree workflow 这些很容易解决,但它搞砸了git子树的工作流程

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. git merge -Xignore-space-change以忽略提交中的空间更改。

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): 您可以在合并中尝试使用--dry-run替代方法( git merge没有--dry-run选项):

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

to see the changes before you actually commit them. 在实际提交之前查看更改。

Use submodules to hold shared work. 使用子模块来保存共享工作。 There is git-slave if you do a lot of work with shared and non-shared projects that need to be coordinated. 如果您对需要协调的共享和非共享项目进行大量工作,那么就有git-slave。 Your line ending storage disparity will disappear. 您的行结束存储差异将消失。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM