17

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

4

2 回答 2

3

这不是解决您的根本问题,而是缓解它。您可以使用
git merge -Xignore-space-change 忽略提交中的空间更改。

你的行尾可能有问题。--dry-run您可以在合并中尝试替代方案(git merge没有--dry-run选项):

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

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

于 2016-10-26T20:35:43.940 回答
-3

使用子模块来保存共享工作。如果您对需要协调的共享和非共享项目进行大量工作,则有 git-slave。您的行尾存储差异将消失。

于 2011-12-30T20:04:51.340 回答