PR期间Git合并冲突 [英] Git merge conflicts during PRs
问题描述
我做了一些不寻常的设置,即首先建立存储库,而不是用项目文件填充 master
分支,而是创建并填充了 transfer
分支.然后,文件通过PR进入 development
,然后又通过另一个PR进入 master
.
I did a bit unusual setup where repositories were first set up, instead of populating the master
branch with project files, a transfer
branch was created and populated. Then, files were pull into development
via PR and then again into master
via another PR.
接下来,主题分支将在 development
分支之外创建.完成后,将为 topic
->创建PR. development
和另一个用于 development
的PR-> master
.但是,在第二次PR development
->中,我不断遇到合并冲突. master
,例如在Azure DevOps上的两者都添加,两者都编辑等.
And, going forward, topic branches are created off development
branch. Once done, PR was created for topic
--> development
and another PR for development
--> master
. But, I keep getting merge conflict for second PR development
--> master
such as Added in Both, Edited in Both etc on Azure DevOps.
现在,只有壁球合并用于将PR完成到 development
和 master
中.
Right now, only squash merge is used to complete PR into both development
and master
.
我想知道的是,我看到的那些合并冲突是否由于存储库或壁球合并的原始设置而发生.PR用于 development
和 master
的PR的 diff
也包含许多我不期望的更改.
What I want to know is whether those merge conflicts I am seeing happen due to the original setup of the repository or squash merge. The diff
of PR for development
and master
also contains a lot of changes I do not expect, too.
我无法解决这个问题.
推荐答案
发生冲突是因为您使用的是南瓜".合并并不断重新整合一个分支.与南瓜"您没有进行真正的合并(换句话说:历史未连接).相反,您是在 master
分支上创建一个新的提交.
The conflicts happen because you are using "squash" merge and continuously reintegrate one branch. With "squash" you are not doing a real merge (in other words: the history is not connected). Instead you are creating a single new commit on master
branch.
稍后,当您尝试将 development
合并到 master
时,所有先前的开发更改将再次合并(但它们已经存在于 master
).这就是为什么您会看到冲突.
Later, when you try to merge development
to master
, all previous changes from development would be merged again (but they already exist in master
). That's why you see conflicts.
我看到2个选项:
- 请勿使用壁球"完全不需要重新整合分支并使用常规合并
- 每次合并后,从
master
重新创建development
这篇关于PR期间Git合并冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!