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

有些话、适合烂在心里 提交于 2020-01-01 07:45:34

问题


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


回答1:


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.




回答2:


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. Your line ending storage disparity will disappear.



来源:https://stackoverflow.com/questions/8672095/git-reports-merge-conflict-with-no-changes-empty-lines-using-git-subtree

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!