git 报告合并冲突,没有任何更改,空行(使用 git-subtree)

发布于 2024-12-23 12:23:42 字数 665 浏览 1 评论 0原文

我正在测试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

满意归宿 2024-12-30 12:23:42

这不是根本问题的解决方案,而是缓解问题的方法。你可以使用
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.

朕就是辣么酷 2024-12-30 12:23:42

使用子模块来保存共享工作。如果您需要对需要协调的共享和非共享项目进行大量工作,那么可以使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文