简体   繁体   English

Git合并提交为冲突创造了更多机会

[英]Git merge commit creates more opportunity for conflicts

I'm trying to understand why I have to do merges multiple times in a long running branch. 我试图理解为什么我必须在一个长期运行的分支中多次合并。

Once in a while I merge master back into my branch, resolve conflict and commit. 偶尔我会将master合并回我的分支,解决冲突并提交。 But I realize that this later commit is more modification to a file that may end up creating more merge conflict if the same files are modified in the master branch. 但是我意识到,以后提交的内容是对文件的更多修改,如果在master分支中修改了相同的文件,则最终可能会产生更多的合并冲突。

I feel that as long as more modifications to the same file occurs in the master branch I will have to manually edit conflicts even though I'm not making any other changes to said files in my branch. 我觉得只要在master分支中对同一文件进行更多修改,即使我不在分支中对上述文件进行任何其他更改,我也必须手动编辑冲突。

How do people deal with this? 人们如何处理呢?

If you have long running branch you can always do 如果您的分支机构长期运作,则可以随时进行

git fetch origin
git rebase origin/master

to be always on top of the master branch. 始终位于master分支的顶部。


But as @David Deutsch said you do not want to do that if your branch is already pushed to origin. 但是正如@David Deutsch所说的,如果您的分支机构已经被推到原来的位置,您就不想这样做。

Nothing will prevent you from merge conflicts. 没有什么可以防止您发生合并冲突。 Conflict is conflict. 冲突就是冲突。 If someone else is working with you on this file this is indication that you have some smell in the project (SRP principle violated). 如果其他人正在与您一起处理此文件,则表明您在项目中有某种气味(违反了SRP原则)。 The only way to reduce conflicts is to have only short living branches. 减少冲突的唯一方法是只有短暂的生命分支。

是的,只有快速合并,无论是1个还是n个使用某个功能的用户,每个新的“发行版”都有其自己的分支,并且所有提交都相互弹出

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM