git 如何解决 VSTS 中拉取请求中的合并冲突?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46692989/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:08:47  来源:igfitidea点击:

How to resolve merge conflict in pull request in VSTS?

gitazure-devopspull-requestmerge-conflict-resolution

提问by Liero

I've created pull request I got into this:

我已经创建了我进入这个的拉取请求:

enter image description here

在此处输入图片说明

"Approve" button does nothing and complete is disabled.

“批准”按钮什么也不做,完成被禁用。

How do I resolve this confligt in pull request?

如何在拉取请求中解决此冲突?

采纳答案by jessehouwing

Update

更新

Microsoft just added browser based merges. This may get you out of a pickle for small conflicts.

微软刚刚添加了基于浏览器的合并。这可能会让你摆脱小冲突的困境。

And offers improved visualizations of the different scenarios as of Sprint 150.

并提供了从 Sprint 150 开始的不同场景的改进可视化

For more complex situations:

对于更复杂的情况:

You have two options to resolve the conflict, reverse-integrate the changes from the target branch (which creates additional merge commits), or rebase on the target branch (which leaves your history nice and clean).

您有两个选项来解决冲突,反向集成来自目标分支的更改(这会创建额外的合并提交),或者基于目标分支(这使您的历史记录干净整洁)。



Merge from target to current branch prior to completing the PR.

在完成 PR 之前从目标合并到当前分支。

You need to clone the repo locally, perform a merge from the target branch to your branch and push those changes up to the repository. VSTS will detect the changes and update the pull request.

您需要在本地克隆 repo,执行从目标分支到您的分支的合并并将这些更改推送到存储库。VSTS 将检测更改并更新拉取请求。

            -------o3              PR
           /
---------o1-o2                     target

Thus merge target (o2)to PR:

因此合并target (o2)PR

            -------o3-o4           PR
           /          /
---------o1----------o2            target

Then complete the PR

然后完成PR

            -------o3-o4           PR
           /          / \
---------o1----------o2--o5        target


Rebase the PR branch to include the latest changes on target

重新设置 PR 分支以包含目标上的最新更改

Alternatively, you can clone the repo locally, rebase the PR branch on the latest version of the target branch, solve all issues from the rebase and force-push the changes back to the PR branch. VSTS will detect the changes and update the pull request.

或者,您可以在本地克隆 repo,将 PR 分支重新设置为目标分支的最新版本,解决所有问题并强制将更改推送回 PR 分支。VSTS 将检测更改并更新拉取请求。

            -------o3              PR
           /
---------o1-o2                     target

Thus rebase o3onto o2:

因此变基o3o2

              -------o3            PR
             /
---------o1-o2                     target

Then complete the PR(with Fast-forward merge in the case below):

然后完成PR(在下面的情况下使用快进合并):

---------o1-o2-o3                  target

回答by sky91

  1. Open your project with Visual Studio.
  2. Open View> Team Explorer
  3. Change to Branchestab.
  4. Double click to the branch you intend to merge (e.g. dev).
  5. Right Click > Merge From > Select
    Merge from branch: master,
    Into current branch: dev
  6. Click Mergebutton
  7. Choose the conflict file(s)
  8. Then resolve the conflicts. You can click the left or right checkbox for the section you want to include.
  9. Then commit the merge
  10. Done.
  1. 使用 Visual Studio 打开您的项目。
  2. 打开视图>团队资源管理器
  3. 更改为分支选项卡。
  4. 双击要合并的分支(例如 dev)。
  5. 右键单击 > 合并自 > 选择
    合并自分支:master
    进入当前分支:dev
  6. 单击合并按钮
  7. 选择冲突文件
  8. 然后解决冲突。您可以单击要包含的部分的左侧或右侧复选框。
  9. 然后提交合并
  10. 完毕。

回答by BipinR

You could do the above technique by @jessiehouwing or use the new plug-in. MicrosoftDevLabs released the link to the plugin to resolve conflicts. The link to plugin is given below https://marketplace.visualstudio.com/items?itemName=ms-devlabs.conflicts-tab

您可以通过@jessiehouwing 执行上述技术或使用新插件。MicrosoftDevLabs 发布了该插件的链接以解决冲突。插件链接如下 https://marketplace.visualstudio.com/items?itemName=ms-devlabs.conflicts-tab