Git在请求请求中发生冲突

编程入门 行业动态 更新时间:2024-10-28 02:35:03
本文介绍了Git在请求请求中发生冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有2个分支-master和develop

我一直在我的develop分支中执行一些拉取请求,其中包含5个项目,其中与master中的项目数相同.

I have been doing some pull requests in my develop branch where it contains 5 items, in which it is the same as the number of items in master.

但是,有人在master分支中做了一些提交并将pushed放入了更多项目,因此,现在有8个项目.

However, someone did some commits and pushed in a few more items into the master branch, and hence now it has 8 items.

由于我在develop中的请求还没有被批准/合并,每当我尝试更新请求时,我都会收到一条消息,提示This pull request can't be merged. You will need to resolve conflicts to be able to merge并要求我执行以下操作:

As my pull request in the develop is still not yet approved/merged, whenever I tried to update my pull request, I am getting the message stating that This pull request can't be merged. You will need to resolve conflicts to be able to merge and asked me to do the following:

git fetch origin master git checkout develop git merge FETCH_HEAD git commit git push origin HEAD

这是在我推送"我的提交之后发生的,有时使我感到困惑.然后我意识到这是要我重新添加并重新提交其他3个新项目.那么这是否意味着我必须确保我的这两个分支之间的项目和内容应始终相同?我一直使用git pull/fetch,但是有什么更好的方法可以确保吗?

And this happens after I have 'pushed' out my commits, making me confused at times. Then I realized that it is asking me to re-add and re-commit in the additional 3 new items. So does this means I must ensure that the items and contents between these 2 branches of mine should be the same as always? I have always used git pull/fetch but will there be a better way for me to make sure?

推荐答案

这意味着GitHub希望将您的PR分支合并到master中,但不能这样做,因为存在冲突.正如您在问题注释中讨论的那样,解决此问题的最佳方法(通常)是在命令行上将master分支合并到develop中.这将向您显示冲突并要求您解决它们.完成并推动该合并后,可以使用GitHub上的绿色按钮将PR合并回master.

What this means is that GitHub would like to merge your PR branch into master, but it can't, because there are conflicts. As you've discussed in the question comments, the best way to deal with this (usually) is to merge your master branch into develop on the command line. That will show you the conflicts and ask you to resolve them. Once you've completed and pushed that merge, the PR will be mergeable back into master using the green button on GitHub.

您可以简单地将您的deploy分支合并到master(我知道听起来更明智).在这种情况下,您将完全绕开PR.您必须关闭PR的未合并",然后分别将合并提交手动推送到master.

You could simply merge your deploy branch into master (which I realize sounds a bit more sensible). In that case, you'd be bypassing the PR entirely. You'd have to close the PR "unmerged", and separately you'd manually push the merge commit to master.

第一种方式,

  • 通过使用PR合并到GitHub上的master,您可以进行更好的审核;
  • 您可以给您的团队一个机会,使其在合并后的代码进入master之前对其进行检查;和
  • 如果您具有检查PR的自动测试(例如Travis CI或CircleCI),则可以给他们提供运行合并代码的机会.
  • you make a better audit trail by merging to master on GitHub, using the PR;
  • you give your team a chance to review your code after the merge, before it lands on master; and
  • if you have automatic tests (such as Travis CI or CircleCI) which check PRs, you give them a chance to run your merged code as well.
  • 更多推荐

    Git在请求请求中发生冲突

    本文发布于:2023-10-22 09:23:32,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1517108.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:发生冲突   Git

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!