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 to master (no conflict)
branch3 to master (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 of branch2 to master)
Git will ask you to choose which content to keep ("3", "2", or both).
First, do the merges after:
git config merge.conflictstyle diff3
作者创建了一个Git仓库并添加文本文件用于学习。在主分支添加内容后创建新分支并追加不同内容,询问冲突产生原因。解释了合并分支时冲突的情况,如将branch3合并到master会产生冲突,还提到可通过设置配置来处理冲突。
540

被折叠的 条评论
为什么被折叠?



