git合并冲突如何发生? [英] how does exactly a git merge conflict happen?
问题描述
我制作了一个git存储库并为其添加了一个文本文件。这是100%的学习目的。
-
我在文本文件中添加了1并将其提交给主文件。
-
从master创建了一个新的分支并附加了2。最后,从master创建了一个分支,并添加了3。
您可以解释一下这种情况或其他任何情况下可能发生的冲突吗? b $ b
如果合并,您将会遇到冲突: > 那是因为: Git会要求您选择哪些内容保留(3,2或两者)。 首先,在之后进行合并: branch2
至 master
(无冲突)
branch3
至 master
(冲突):
master
line empty)
branch3
(第二行包括3)
master
的最后一行(第二行包含2,来自 branch2 $ c $的合并c> to
master
)
git config merge.conflictstyle diff3
请参阅修复Git中的合并冲突?。
I have made a git repository and added a text file to it. This is 100% for learning purpose.
I added "1" to the text file and committed it to master.
Created a new branch from master and appended "2".
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
tomaster
(no conflict)branch3
tomaster
(conflict):
That is because:
- 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 ofbranch2
tomaster
)
Git will ask you to choose which content to keep ("3", "2", or both).
First, do the merges after:
git config merge.conflictstyle diff3
See "Fix merge conflicts in Git?".
这篇关于git合并冲突如何发生?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!