究竟是什么导致git中的合并冲突? [英] What exactly does cause merge conflict in git?

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

问题描述

我想知道何时确切发生合并冲突.我的假设是在两个分支中都修改了文件时会发生这种情况.更详细地讲,如果在一个分支中修改了文件,但未在另一个分支中修改过,则将使用已修改"版本(旧"版本替换为新"版本).

I wonder when exactly a merge conflict occurs. My assumption is that it occurs when a file was modified in both branches. In more details, if a file was modified in one branch but not in another one, the "modified" version will be used (the "old" version is replaced by a "new" one).

如果有两个新"版本(来自两个分支),则git不知道要使用哪个版本,因此需要手动合并.

If there are two "new" versions (coming from two branches), git does not know what version to use, so a manual merge is required.

但是,我不确定我的理解.我可以想象,即使在两个分支中都修改了相同的文件,如果对彼此相距足够远的地方进行修改,也不会发生合并冲突.

However, I am not sure about my understanding. I can imagine that even if the same file was modified in both branches there is no merge conflict if the modifications are done to places that are far enough from each other.

推荐答案

文件的一行(一行)由多个人同时编辑时引发合并冲突.不一定必须位于2个不同的分支中.

Merge conflicts raised when a line (or lines) in a file is edited by more then one person at the same time. Doesn't necessarily have to be in 2 different branches.

第一个推送更改后,其他尝试推送更改的人会偶然发现合并冲突.

After the first one pushes his changes, any other who will try to push his changes will stumble upon a merge conflict.

基本上,git系统可以单独处理合并.但是在这种情况下,它无法确定哪个版本是正确的版本,从而引发合并冲突.

Basically the git system can handle merging alone. But in this scenario it cant tell which edition is the right one thus raising a merge conflict.

有关更多信息,请参见此帖子: 什么时候会发生git合并冲突

See this post for more info: when exactly does a git merge conflict arise

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

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