git 报告合并冲突,没有任何更改,空行(使用 git-subtree)
我正在测试使用 git-subtree 将库存储库合并到更大的项目中。原则上看起来很棒。有时,当我执行“git subtree pull”时,我会遇到如下合并冲突:
<<<<<<< HEAD
=======
An inserted line from the lib repo
>>>>>>> 4d348903449ebb584ab224cb34c6038fbf6b352d
这是在库存储库中进行的更改,合并到本地尚未修改的文件中。或者另一个例子,我在本地项目存储库中添加了一行,但在属于正在合并的子树的文件中添加了一行:
<<<<<<< HEAD
Another inserted line
=======
>>>>>>> 4d348903449ebb584ab224cb34c6038fbf6b352d
为什么 git 将这些报告为合并冲突,但报告为冲突的区域为空?有什么办法可以预防吗?
这些很容易解决,但它扰乱了 git-subtree 工作流程
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不是根本问题的解决方案,而是缓解问题的方法。你可以使用
git merge -Xignore-space-change
忽略提交中的空间更改。
这可能是你的行结尾有问题。您可以在合并中尝试使用
--dry-run
替代方案(git merge
没有--dry-run
选项):$git merge -Xignore-space-change --no-commit --no-ff $BRANCH
在实际提交之前查看更改。
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-slave。您的行尾存储差异将消失。
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.