我和我的团队已经使用git大约一年了--我们中没有人有过git或任何其他版本控制方面的经验。我们在dev中完成了大部分工作,当我们准备好之后,我们会创建一个发布分支,在需要时进行任何更改,然后将发布分支合并为master。当我们将发行版分支合并到主版中时,我们一直在进行压缩合并,以保持提交历史记录的干净。我们读过很多指南/教程/如何-托斯,每个人都说了不同的话,但这是我们决定要做的。
我注意到的是,每当我们将发布分支合并为master时,总是会出现合并冲突。不是每个文件,而是大约15%的文件。其中大部分看起来不应该是冲突,但它们都是一种冲突。下面是一个例子:
合并前主分支:
<div style="float:right">
<strong>Select Report: </strong>
<select name="report" id="report">
<option value="">-- SELECT REPORT --</option>
<optgroup label="General">
<option value="aganalysis_stats"<?php if($report == 'aganalysis_stats') echo " selected"; ?>>AgAnalysis Stats</option>
</optgroup>
<optgroup label="LSPs">
<option value="lsps_pending_approval_for_current_quarter"<?php if($report == 'lsps_pending_approval_for_current_quarter') echo " selected"; ?>>LSPs Pending Approval for Current Quarter</option>
<option value="members_requiring_lsps"<?php if($report == 'members_requiring_lsps') echo " selected"; ?>>Members Requiring LSPs</option>
<option value="missing_lsps_for_current_quarter"<?php if($report == 'missing_lsps_for_current_quarter') echo " selected"; ?>>Missing LSPs for Current Quarter</option>
</optgroup>
<optgroup label="UCCs">
<option value="uccs_by_branch"<?php if($report == 'uccs_by_branch') echo " selected"; ?>>UCCs by Branch</option>
<option value="uccs_eligible_for_renewal"<?php if($report == 'uccs_eligible_for_renewal') echo " selected"; ?>>UCCs Eligible for Renewal</option>
<option value="uccs_expired"<?php if($report == 'uccs_expired') echo " selected"; ?>>Expired UCCs</option>
</optgroup>
</select>
</div>合并后的主分支:
<div style="float:right">
<strong>Select Report: </strong>
<select name="report" id="report">
<option value="">-- SELECT REPORT --</option>
<optgroup label="Appraisal Requests">
<option value="appraisal_request_stats">Appraisal Request Stats</option>
</optgroup>
<optgroup label="General">
<option value="aganalysis_stats">AgAnalysis Stats</option>
</optgroup>
<optgroup label="LSPs">
<option value="lsps_pending_approval_for_current_quarter">LSPs Pending Approval for Current Quarter</option>
<option value="members_requiring_lsps">Members Requiring LSPs</option>
<option value="missing_lsps_for_current_quarter">Missing LSPs for Current Quarter</option>
</optgroup>
<optgroup label="UCCs">
<<<<<<< HEAD
<option value="uccs_by_branch"<?php if($report == 'uccs_by_branch') echo " selected"; ?>>UCCs by Branch</option>
<option value="uccs_eligible_for_renewal"<?php if($report == 'uccs_eligible_for_renewal') echo " selected"; ?>>UCCs Eligible for Renewal</option>
<option value="uccs_expired"<?php if($report == 'uccs_expired') echo " selected"; ?>>Expired UCCs</option>
=======
<option value="uccs_by_branch">UCCs by Branch</option>
<option value="uccs_eligible_for_renewal">UCCs Eligible for Renewal</option>
<option value="uccs_expired">Expired UCCs</option>
>>>>>>> refs/remotes/origin/dev
</optgroup>
</select>
</div>正如您所看到的,我对“LSP”和“UCC”选项组都做了完全相同的更改。但是,我在“UCC”选项组中只得到一个合并冲突。为什么我会有这种合并冲突?我合并得不对吗?在将分支合并为主服务器时,不应该使用压缩合并吗?我读过很多关于重基、压球、没有快速前进等的东西,我不知道什么是对的,什么是错的。
发布于 2013-12-03 17:58:36
让我帮你回答这些..。希望能帮上忙。
为什么我会有这种合并冲突?
因为git已经发现尝试合并的内容是如此的不同,所以它需要您进行干预,并告诉它应该存在哪些代码。它给您提供的选项是git在主(=======之上)和分支中(低于=======)所具有的选项。
您可以选择一个或进行其他更改,保存文件,并使用新消息提交文件(通常类似于“通过.修复合并冲突”)。
我合并得不对吗?
不是的。Git刚刚找到了一个合并,由于它试图合并的两个分支中存在巨大的差异,它无法自动处理这个合并。
在将分支合并为主服务器时,不应该使用压缩合并吗?
这将根据git用户和git用户的不同而有所不同,但在将分支合并为master之前,我通常会尝试压缩提交。这通常是有帮助的,因为这样就可以合并更少的提交,但并不总是解决合并冲突的问题,因为这些冲突发生在分支不同时。因此,如果master已经从与您的分支相同的第三个分支中更改,那么很可能仍然存在合并冲突。
https://stackoverflow.com/questions/20357451
复制相似问题