本文介绍了VSTS和Git:为什么在合并到master时挤压我的DEV分支会说DEV在master后面还是后面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望当我挠头了解发生的事情以及是否可以纠正此问题时,可以为我提供帮助.

I'm hoping someone can help me with this as I'm scratching my head to understand what is going on, and if it can be rectified.

我目前正在VSTS中从事一个项目,并使用GIT作为代码存储库.我有一个通常的MASTER分支,还有一个DEVELOPMENT分支.然后,我从DEVELOPMENT分支创建功能分支.

I'm currently working on a project in VSTS and using GIT as the code repository. I have the usual MASTER branch, with a DEVELOPMENT branch coming off that. I then create feature branches off the DEVELOPMENT branch.

完成功能分支中的更改后,我将创建一个拉取请求",并将更改成功合并到DEV分支中.然后,DEV分支在MASTER后面显示"0",在MASTER前面显示"x".

When we have finished the changes in the feature branch, I create a Pull Request and can successfully merge the changes into the DEV branch. The DEV branch then shows '0' behind and 'x' ahead of MASTER ... which is correct.

当我们准备将更改合并到MASTER中时,问题就来了.我们创建一个PULL REQUEST来完成此操作,并且更改成功合并到MASTER中.但是... DEV分支现在说MASTER后面是1,而MASTER前面还是x!为什么DEV 1落后于MASTER?为何DEV仍然比MASTER领先? PULL REQUEST之后,MASTER和DEV是否应该同步?也就是说,DEV应该落后0,而MASTER领先0?

The issue comes when we are ready to merge the changes into MASTER. We create a PULL REQUEST to do this and the changes successfully merge into MASTER ... however ... the DEV branch now says that is 1 behind MASTER and still x ahead of MASTER!! Why is DEV 1 behind MASTER? And why is DEV still x ahead of MASTER? After the PULL REQUEST, shouldn't MASTER and DEV be in sync? That is, DEV should be 0 behind, and 0 ahead of MASTER?

很有可能我不能正确理解GIT,但是VSTS中的某些设置是否可能会出错...就像分支策略设置不正确一样?我在MASTER上设置的唯一分支策略(在此阶段)是强制执行合并策略-Squash合并".

There is a very good chance I'm not understanding GIT properly, but could I have some settings in VSTS wrong ... like a branching policy incorrectly set? The only branch policy I have set on MASTER (at this stage) is "Enforce a merge strategy - Squash merge".

谢谢.

推荐答案

南瓜合并是造成您误解的原因.

Squash merge is the cause for your misunderstanding.

当您压缩合并时,开发分支的所有提交都被压缩为一个提交.这就是DEV之所以落后于master的原因,因为它没有提交失败.而且DEV在master之前是x,因为DEV有x不在master内的提交.

When you squash merge, all the commits of your development branch are squashed into one single commit. This is the reason why DEV is 1 behind master, since it doesn't has the squashed commit. Also DEV is x ahead of master because DEV has x commits which aren't in master.

理想情况下,您只应将功能/主题分支合并,这样就可以为每个功能提交一次提交.合并为master时,请勿压榨dev分支.因此,您可以根据需要在master上更改分支策略,并将其放在DEV中.我的建议是让您的开发人员决定何时压扁.在VSTS中完成PR时,它为您提供了一个壁球选项.

Ideally you should only squash merge your feature/topic branches, that will give you one commit per feature. You should not squash your dev branch when you merge into master. So you can change the branch policy on master and put that policy in DEV if you want that. My advice is to let your developers decide when to squash or not. When you complete a PR in VSTS, it gives you an option to squash.

这篇关于VSTS和Git:为什么在合并到master时挤压我的DEV分支会说DEV在master后面还是后面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 05:20