我如何管理与git子模块的冲突? [英] How do I manage conflicts with git submodules?

查看:320
本文介绍了我如何管理与git子模块的冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个git超级项目引用了几个子模块,我试图锁定工作流程以供其他项目成员使用。



问题,可以说我的超级项目名为 supery ,子模块名为 subby 。 (然后简化了我正在做的事情......我实际上并没有使用这些分支的版本,但我认为这是最简单的问题。)



我的 supery 的主分支的标签 v1.0 git项目 subby 引用为子模块。 supery 的分支称为 one.one ,并将子模块的引用更改为指向 v1.1 subby



我可以在每个分支没有问题,但如果我尝试更新 one.one 分支,并且更改了我从 master 分支中的更改一些冲突,我不怎么解决它们。

基本上在运行 git pull之后。 master ,而在 subby 分支中,它看起来会创建额外的子模块。



在pull / merge之前,我从 one.one 分支中获得来自 git submodule 的所需响应:

  $ git checkout master 
$ git submodule
qw3rty ... 321e subby(v1.0)
$ git checkout one.one
$ git submodule
asdfgh ... 456d subby(v1.1)

但是在pull之后,当我运行 git submodule

<$时,它增加了额外的子模块p $ p> $ git pull。 master
自动合并模式
CONFLICT(子模块):在subby中合并冲突 - 需要qu3rty ... 321e
自动合并失败;修复冲突,然后提交结果。

$ git submodule
qw3rty ... 321e subby(v1.0)
asdfgh ... 456d subby(v1.1)
zxcvbn ... 7890 subby(v1.1〜1)

如何删除/忽略不需要的子模块引用并提交我的冲突和变化?或者是否有一个参数可以用于我的原始 git pull ,它将忽略我的子模块?

我之前没有看到过确切的错误。但我猜猜你遇到的麻烦。它看起来像是因为 master one.one 分支超级包含对 subby 子模块的不同引用,当你合并来自 master 的变更时,git不知道哪个ref - v1.0 v1.1 - 应该由 one.one supery



的分支如果是这种情况,那么您需要选择参考你想要的和承诺改变来解决冲突。这正是你使用 reset 命令所做的工作。



这是跟踪不同版本的子模块的一个棘手方面,你的项目。但子模块ref就像您的项目的其他任何组件。如果两个不同分支在连续合并之后继续跟踪相同的子模块参考,那么git应该能够计算出模式,而不会在将来的合并中引起合并冲突。另一方面,如果开关子模块经常参考,则可能需要忍受大量冲突解决。


I have a git superproject that references several submodules and I am trying to lock down a workflow for the rest of the my project members to work within.

For this question, lets say my superproject is called supery and the submodule is called subby. (Then is a simplification of what I'm trying to do...I'm not actually using the branches for versions, but I thought it would be easiest to lay out as a question.)

My master branch of supery has the tag v1.0 of the git project subby referenced as a submodule. The branch of supery called one.one and changed the reference of the submodule to point to the tag v1.1 of subby.

I can work within each of these branches without a hitch, but if I try to update the one.one branch with changes from the master branch I receive some conflicts and I don't how to resolve them.

Basically after running a git pull . master while in the subby branch, it looks like it creates additional submodules.

Before the pull/merge, I get the desired response from git submodule from the one.one branch:

$ git checkout master
$ git submodule
qw3rty...321e subby (v1.0)
$ git checkout one.one
$ git submodule
asdfgh...456d subby (v1.1)

But after the pull, it adds additional submodules when I run git submodule:

$ git pull . master
Auto-merged schema
CONFLICT (submodule): Merge conflict in subby - needs qu3rty...321e
Automatic merge failed; fix conflicts and then commit the results.

$ git submodule
qw3rty...321e subby (v1.0)
asdfgh...456d subby (v1.1)
zxcvbn...7890 subby (v1.1~1)

How do I delete/ignore the unwanted submodule references and commit my conflicts and changes? Or is there a parameter I can use with my original git pull that will ignore my submodules?

解决方案

I have not seen that exact error before. But I have a guess about the trouble you are encountering. It looks like because the master and one.one branches of supery contain different refs for the subby submodule, when you merge changes from master git does not know which ref - v1.0 or v1.1 - should be kept and tracked by the one.one branch of supery.

If that is the case, then you need to select the ref that you want and commit that change to resolve the conflict. Which is exactly what you are doing with the reset command.

This is a tricky aspect of tracking different versions of a submodule in different branches of your project. But the submodule ref is just like any other component of your project. If the two different branches continue to track the same respective submodule refs after successive merges, then git should be able to work out the pattern without raising merge conflicts in future merges. On the other hand you if switch submodule refs frequently you may have to put up with a lot of conflict resolving.

这篇关于我如何管理与git子模块的冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆