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
Azure DevOps - Pull Request Git "Next steps: Manually resolve these conflicts and push new changes to the source branch."
提问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:
我已经做了一个拉取请求将开发代码发送给主人,当我做这个拉取请求时,它告诉我:
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 status
will 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。
回答by Marina Liu
Since you need to keep the files version on dev
branch (keep the source branch while changing files in target branch master
), so you should make changes on master
branch to resolve the conflict files, and be sure you have permission to push changes to master
branch.
由于您需要在dev
分支上保留文件版本(在目标分支中更改文件时保留源分支master
),因此您应该在master
分支上进行更改以解决冲突文件,并确保您有权将更改推送到master
分支。
You can use below options:
您可以使用以下选项:
Option 1: merge directly
方案一:直接合并
In your local repo, you can execute below commands to merge dev
into master
branch while keeping the conflict files version as the dev
branch:
在您的本地存储库中,您可以执行以下命令以合并dev
到master
分支,同时将冲突文件版本保留为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 master
branch:
您可以使用以下命令来解决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 Request
in the Azure DevOps portal. Actually, I could just Refresh changes for the existing Pull Request
and the auto merge conflicts were resolved.
我不得不做一个rebase
. 必须遍历所有提交并应用我的更改 - 它们非常广泛,重命名命名空间和方法名称等。然后让我继续Pull Request
在 Azure DevOps 门户中做一个。实际上,我可以只刷新现有更改Pull Request
并解决自动合并冲突。
Merging the code did not resolve the issue, only rebase
worked.
合并代码并没有解决问题,只能rebase
工作。