简体   繁体   English

发布后 Gitflow 在 master 后面开发分支

[英]Gitflow develop branch behind master after a release

We are using Gitflow for our git branch workflow (through TFS).我们将 Gitflow 用于我们的 git 分支工作流程(通过 TFS)。 When a release is successful we do the following当发布成功时,我们执行以下操作

  1. Pull request from release to master从发布到主的拉取请求
  2. Pull request from release to develop从发布到开发的拉取请求

Step 1 creates a commit (Merged PR XXX: Merge release to master)第 1 步创建提交(Merged PR XXX: Merge release to master)

Step 2 creates a commit (Merged PR YYY: Merge release to develop)第 2 步创建提交(Merged PR YYY:Merge release to develop)

When I look at our branches it says that develop is one commit behind master.当我查看我们的分支时,它说 develop 是 master 之后的一次提交。 This is because the commit (Merged PR: XXX) is not on develop.这是因为提交(合并 PR:XXX)不在开发阶段。

Is the correct procedure to simply create another pull request from master to develop (even though there are no changes in pull request)?简单地从master创建另一个pull request到develop(即使pull request没有变化)是正确的程序吗?

I don't see this on the standard Gitflow model我在标准Gitflow 模型上看不到这个

This will be fiction length, so my apologies. 这将是虚构的长度,所以我道歉。 The short answer I'm submitting is the completion of a git flow release should result in develop being a commit ahead of master based on how git flow origniator Vincent Driessen implemented his own git-flow scripts . 答案很简单,我提交是一个git流释放的完成应该导致develop是一个犯提前 master基于Git的流动origniator如何文森Driessen的实现自己的混帐流脚本

What ... git-flow scripts ? 什么... git-flow 脚本

I'm not sure about your experience with git-flow so forgive me if I'm stating the obvious. 我不确定你对git-flow体验,如果我说明显git-flow ,请原谅我。 The git-flow spec has a set of scripts to make its use easier. git-flow规范有一组脚本,可以更轻松地使用它。 Git flow scripts ship out of the box with Git for Windows which I'm assuming you're using based on your TFS reference. Git流脚本开箱即用Git for Windows ,我假设你正在使用基于你的TFS参考。

Result of a Recent "v2.1.0" release 最近的“v2.1.0”版本的结果

Let's check the history of a recent release via Git Bash 让我们通过Git Bash查看最近发布的历史记录

$ git log --oneline --graph --decorate

which yeilds 哪个

git flow release finish的结果

In the image above you'll notice 在上图中你会注意到

  1. A file upload feature was merged into develop. 文件上传功能已合并到开发中。 At this point, I wanted to release the product. 此时,我想发布该产品。
  2. To release, I issued $ git flow release start v2.1.0 . 要发布,我发布了$ git flow release start v2.1.0
  3. The "git flow release start ..." command automatically created branch release/v2.1.0 . “git flow release start ...”命令自动创建分支release/v2.1.0 This branch only contains one commit -- an increase in the version number. 此分支仅包含一个提交 - 版本号的增加。
  4. At this point I've tested and am happy with the release so I finish it using $ git flow release finish -k 在这一点上,我已经测试并对发布很满意,所以我使用$ git flow release finish -k完成它
  5. The "git flow release finish" command will in order “git flow release finish”命令将按顺序排列
    • Merge branch release/v2.1.0 into branch master 将分支release/v2.1.0合并到分支master
    • Create an annotated tag for release v2.1.0 为发行版v2.1.0创建带注释的标记
    • Merge branch master into develop to ensure all commits in the release branch make their way back into development of the next release. 将分支master合并到develop以确保发布分支中的所有提交都返回到下一版本的开发中。

But what if I'm using TFS PR's? 但是如果我使用TFS PR呢?

If you're using TFS PRs in your workflow you probably see something like this when you're ready to complete a release PR. 如果您在工作流程中使用TFS PR,那么当您准备完成发布PR时,您可能会看到类似的内容。

在此输入图像描述

In my shop, we use PRs too, but I merge locally using $ git flow release finish -k , then push the master and develop branches. 在我的商店,我们也使用PR,但是我使用$ git flow release finish -k在本地合并,然后推送masterdevelop分支。 TFS recognizes that the release branch has already been merged and will give you the option to "Close" rather than "Complete" the PR as shown below. TFS识别出已经合并了发布分支,并且可以选择“关闭”而不是“完成”PR,如下所示。

在此输入图像描述

I've never done the extra merge you describe (or been on a team that did). 我从来没有完成你描述的额外合并(或者是在一个团队中)。 I guess you could merge master to develop instead of merging the release to develop if you really wanted to - or, at least, I can't think of anything that would go wrong... But really, what's wrong with develop being "behind"? 我想你可以合并master来开发而不是合并发布,如果你真的想要开发 - 或者,至少,我想不出任何会出错的东西......但是真的, develop成为“背后的错误” “? It's basically the normal state of affairs in gitflow IMO. 这基本上是gitflow IMO的正常状态。

In your scenario, the develop branch should have one commit behind master, and one commit ahead master (due to Merged PR YYY). 在您的场景中,开发分支应该在master之后有一个提交,并且一个提交在master之前(由于Merged PR YYY)。 If you create another pull request from master to develop, the develop branch will have another new commit (Merged PR ZZZ) and it will have one commit ahead master (Is it what you want?). 如果你从master创建另一个pull请求来开发,那么develop分支将有另一个新的提交(Merged PR ZZZ),它将有一个提前提交master(它是你想要的吗?)。

Instead of creating a Pull request from release to develop, you could just merge from master to develop. 您可以从主服务器开发到开发,而不是从发布版本开始创建Pull请求。

TL;DR: you should back-merge the release tag (or master) into develop, instead of back-merging the release branch into develop, contrary to what the original article and most popular sources say, because of an issue with git describe TL;DR:你应该将发布标签(或主)反向合并到开发中,而不是将发布分支反向合并到开发中,这与原始文章和大多数流行来源所说的相反,因为git describe存在问题

In the original article , and in the git extension from its author Vincent Driessen aka nvie, the command is:原始文章及其作者 Vincent Driessen aka nvie 的git 扩展中,命令是:

git merge --no-ff $RELEASE_BRANCH

But this behaviour was causing an issue with git describe , so a PR was open, implementing the following command instead:但是这种行为导致git describe出现问题,因此打开了一个PR ,改为执行以下命令:

git merge --no-ff $TAGNAME

(or, if their's no tag, git merge --no-ff master ) (或者,如果他们没有标签, git merge --no-ff master

Vincent Driessen approved this change, but apparently never got the time to make it official. Vincent Driessen批准了这一变化,但显然从未有时间将其正式化。

Then, since its extension was lacking active support, its fork gitflow-avh started, implementing the new behaviour, and became the new standard (the default on Windows and Ubuntu for example).然后,由于它的扩展缺乏积极的支持,它的分支gitflow-avh开始了,实现了新的行为,并成为了新的标准(例如 Windows 和 Ubuntu 上的默认值)。

So, in summary, the behaviour of git flow release finish should be something like:所以,总而言之, git flow release finish的行为应该是这样的:

git checkout master
git merge --no-ff $RELEASE_BRANCH
git tag -a $TAGNAME
git checkout develop
git merge --no-ff $TAGNAME
git branch -d $RELEASE_BRANCH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM