Azure DevOps - Pull Request Git“后续步骤:手动解决这些冲突并将新更改推送到源分支。”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48371911/
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:13:54  来源:igfitidea点击:

Azure DevOps - Pull Request Git "Next steps: Manually resolve these conflicts and push new changes to the source branch."

gitazure-devops

提问by CBBSpike

I have created a branch named dev.

我创建了一个名为 dev 的分支。

I have done a pull request to send dev code to master, when I do this pull request it tell me: enter image description here

我已经做了一个拉取请求将开发代码发送给主人,当我做这个拉取请求时,它告诉我: 在此处输入图片说明

50+ conflicts prevent automatic merging "Next steps: Manually resolve these conflicts and push new changes to the source branch."

50 多个冲突阻止自动合并“下一步:手动解决这些冲突并将新更改推送到源分支。”

Where do I go from here? I just want all the dev branch to replace whatever is in master. I see no options to resolve these conflicts.

我从这里去哪里?我只想让所有的 dev 分支替换 master 中的任何内容。我看不到解决这些冲突的选项。

回答by Harshil Lodhi

You will have to do the following on your PC

您必须在 PC 上执行以下操作

On branch dev

在分行 dev

$ git pull --no-rebase origin master- This will create a merge commit and you will have to resolve the conflicts in the files which are changed both on dev and master. git statuswill show the list of files with conflicting changes.

$ git pull --no-rebase origin master- 这将创建一个合并提交,您必须解决在 dev 和 master 上更改的文件中的冲突。git status将显示具有冲突更改的文件列表。

After resolving conflicts, commit all the changes and push your branch. After that you should be able to complete the PR.

解决冲突后,提交所有更改并推送您的分支。之后,您应该能够完成 PR。

FYI: --no-rebasemakes sure that a merge is done even if the pull behavior is overwritten to default to rebase.

仅供参考:-- no-rebase确保合并完成,即使拉取行为被覆盖为默认为 rebase。

Help link for more details

帮助链接了解更多详情

回答by Marina Liu

Since you need to keep the files version on devbranch (keep the source branch while changing files in target branch master), so you should make changes on masterbranch to resolve the conflict files, and be sure you have permission to push changes to masterbranch.

由于您需要在dev分支上保留文件版本(在目标分支中更改文件时保留源分支master),因此您应该在master分支上进行更改以解决冲突文件,并确保您有权将更改推送到master分支。

You can use below options:

您可以使用以下选项:

Option 1: merge directly

方案一:直接合并

In your local repo, you can execute below commands to merge devinto masterbranch while keeping the conflict files version as the devbranch:

在您的本地存储库中,您可以执行以下命令以合并devmaster分支,同时将冲突文件版本保留为dev分支:

git checkout master
git merge dev -X theirs
git push origin master

And in the existing pull request you created, it will shows the branch has been merged. So you can abandon the pull request.

在您创建的现有拉取请求中,它将显示分支已合并。所以你可以放弃拉取请求。

Option 2: still merge via pull request (resolve conflicts on master branch)

选项 2:仍然通过 pull request 合并(解决 master 分支上的冲突)

You can use below commands to resolve conflicts in masterbranch:

您可以使用以下命令来解决master分支中的冲突:

# In yout local repo
git checkout master
git checkout dev -- .
git commit -m 'replace master branch version by dev for the conflict files'
git push origin master 

While the changes in existing pull request won't be updated if new commit(s) pushs to the target branch (master). And you can find the similar report Pull request diff does not update when a commit from the PR is merged to the target via another branch.

如果新提交推送到目标分支(主),则现有拉取请求中的更改不会更新。当来自 PR 的提交通过另一个分支合并到目标时,您会发现类似的报告Pull request diff does not update

That means, the pull request in the web page still show the conflicts. You should abandon the existing pull request and reactivate (or create a new one) to merge dev into master branch.

这意味着,网页中的拉取请求仍然显示冲突。你应该放弃现有的 pull request 并重新激活(或创建一个新的)以将 dev 合并到 master 分支。

回答by Scott Koland

I had to do a rebase. Had to walk through all the commits and apply my changes - they were pretty extensive, renaming namespaces & method names, etc. This then let me continue to do a Pull Requestin the Azure DevOps portal. Actually, I could just Refresh changes for the existing Pull Requestand the auto merge conflicts were resolved.

我不得不做一个rebase. 必须遍历所有提交并应用我的更改 - 它们非常广泛,重命名命名空间和方法名称等。然后让我继续Pull Request在 Azure DevOps 门户中做一个。实际上,我可以只刷新现有更改Pull Request并解决自动合并冲突。

Merging the code did not resolve the issue, only rebaseworked.

合并代码并没有解决问题,只能rebase工作。