合并冲突到底是什么? [英] What exactly is a merge conflict?

查看:60
本文介绍了合并冲突到底是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个git存储库,并向其中添加了一个文本文件.这是100%用于学习目的.

I have made a git repository and added a text file to it. This is 100% for learning purpose.

  1. 我在文本文件中添加了"1",并将其提交给master.

  1. I added "1" to the text file and committed it to master.

从master创建一个新分支,并附加"2".

Created a new branch from master and appended "2".

最后,从master创建一个分支,并附加"3".

Finally, created a branch from master and appended "3".

您能否解释一下在这种情况或任何其他情况下如何发生冲突?

Could you please explain how a conflict may occur in this, or any other, scenario?

推荐答案

如果合并,则会发生冲突:

You will have a conflict if you merge:

  • branch2 master (无冲突)
  • branch3 master (冲突):
  • branch2 to master (no conflict)
  • branch3 to master (conflict):

那是因为:

  • 共同祖先是 master (第二行为空)
  • 源内容为 branch3 (第二行包括"3")
  • 目标内容是最新的 master (第二行包括"2",从 branch2 合并到 master )
  • The common ancestor would be master (with a second line empty)
  • the source content is branch3 (with a second line including "3")
  • the destination content is on latest of master (with a second line including "2", from the merge of branch2 to master)

Git会要求您选择保留哪些内容("3","2"或两者).

Git will ask you to choose which content to keep ("3", "2", or both).

首先,请在进行合并:

git config merge.conflictstyle diff3

请参见"要修复Git中的合并冲突?.

这篇关于合并冲突到底是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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