Git的主站热修复程序最终领先2位和落后2位 [英] Git hot-fix to master ends up 2 ahead and 2 behind

查看:77
本文介绍了Git的主站热修复程序最终领先2位和落后2位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是git的新手,所以这可能很简单,我在Visual Studio Online中创建了两个分支

I'm new to git so this might be simple, I've created two branches in Visual Studio Online

  • 主-具有策略(因此拉请求仅更新)
  • 开发-具有策略(因此仅提取请求以进行更新)

要执行此修复程序,我从主服务器创建了一个分支,称为 hotfix ,进行了更改+同步,并创建了一个拉取请求以将其检入主服务器.

To do a hot-fix, I created a branch from master called hotfix, made the change + synced, and create a pull request to check it into master.

拉取请求完成后,您可以选择将更改转换为新分支并创建一个新的拉取请求,我对 develop 分支做了此操作.

Once the pull request is complete you get the option to cherry-pick that change into a new branch and create a new pull request, which I did to the develop branch.

现在两者都发生了变化,但是师父现在说这是前2位和后2位.这似乎是错误的.

The changes are now in both, but master is now saying it's 2 ahead and 2 behind. This seems wrong.

我做错了什么?

推荐答案

这是导致您在完成拉取请求合并hot-fix分支到master后实际上没有合并masterdevelop 强>.相反,您可以选择将hot-fix分支更改为develop分支.

It’s caused you actually did no merge master into develop after completing the pull request merge hot-fix branch into master. Instead you cherry-pick the the changes from hot-fix branch to develop branch.

让我们用下面的图表说明步骤(如果master分支和develop分支的提交历史记录不如下,由于机制相同,您还可以参考以下步骤):

Let’s illustrate the steps with below graphs (if the master branch and develop branch commit histories were not as below, you can also refer below steps since the mechanism are same):

首先假设您的master分支和develop分支提交历史记录如下:

Assume your master branch and develop branch commit history as below at first:

…---A---B---D    develop
         \
          C      master

然后您创建了hot-fix并在以下提交历史记录中作为提交EF进行更改:

Then you created hot-fix and make changes as commits E and F in below commit history:

…---A---B---D    develop
         \
          C     master
           \
            E---F  hot-fix

然后创建一个PR,以将hot-fix合并到master,并完成PR,提交历史将为:

Then create a PR to merge hot-fix into master, and complete the PR, the commit history will be:

…---A---B---D    develop
         \
          C-------G   master
           \     /
            E---F  hot-fix

当您将hot-fix分支的更改(提交EF)樱桃选择到另一个分支(develop)时,将创建一个新的主题分支hot-fix-on-develop,其中的更改来自develop分支顶部的>分支,提交历史记录为:

When you cherry-pick the changes (commits E and F) from hot-fix branch to another branch (develop), there will create a new topic branch hot-fix-on-develop with the changes from hot-fix branch on the top of your develop branch, and the commit history as:

              E'---F'  hot-fix-on-develop
             /
…---A---B---D    develop
         \
          C-------F   master
           \     /
            E---F  hot-fix

然后,如果您创建PR以将hot-fix-on-develop分支合并到develop分支中,并且在完成PR之后,提交历史记录将为:

And if you create the PR to merge hot-fix-on-develop branch into develop branch, and after completing the PR, the commit history will be:

              E'---F'   hot-fix-on-develop
             /      \
…---A---B---D--------G    develop
         \
          C-------F   master
           \     /
            E---F  hot-fix

如果将develop设置为比较分支,则master分支位于两个提交GD的后面,并且位于两个提交CF的前面.

And if you set develop as the compare branch, then master branch is behind two commits G and D, and ahead two commits C and F.

这篇关于Git的主站热修复程序最终领先2位和落后2位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆