git “集成分支”的目的是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4428722/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:50:12  来源:igfitidea点击:

What is the purpose of an "integration branch"?

gitgit-branch

提问by Ben Aston

If a branching strategy consists of nfeature branches, a "master" (mainline) and an "integration" branch. What is the purpose of the integration branch? Why can testing and integration not be performed on the feature branch itself?

如果一个分支策略由n 个特征分支、一个“主”(主线)和一个“集成”分支组成。集成分支的目的是什么?为什么不能在功能分支本身上进行测试和集成?

回答by Marcelo Cantos

Because it's a feature branch. It should only contain changes pertaining to the one feature. The integration branch is where you bring multiple features together for testing, before the final push onto master.

因为它是一个功能分支。它应该只包含与一项功能有关的更改。在最终推送到 master 之前,集成分支是您将多个功能组合在一起进行测试的地方。

Of course, you don't haveto separate things this way. You coulddo integration on feature branches, just as you coulddo all your work on master. But separation of concerns is a good thing.

当然,你不要分离的东西这样。您可以在功能分支上进行集成,就像您可以在 master 上完成所有工作一样。但是关注点分离是一件好事。

回答by Hanno Fietz

To be a bit more specific on why exactly "separation is good": The purpose of the integration branch is to determine whether new features work not only on their own, but also in combination with other new features. This means that they might not, the features might cause conflicts that take a while to resolve.

更具体地说明为什么“分离是好的”:集成分支的目的是确定新功能是否不仅可以单独使用,还可以与其他新功能结合使用。这意味着他们可能不会,这些功能可能会导致需要一段时间才能解决的冲突。

However, you still might want to start deploying a subset of the new features to the mainline branch, so you don't block all features because an incompatibility between two of them.

但是,您可能仍然希望开始将新功能的一个子集部署到主线分支,因此您不会因为其中两个功能之间的不兼容而阻止所有功能。

Now, if you had already merged feature branches into one another, you will have a hard time merging them separately into the mainline. It's not entirely impossible, but it's certainly a hassle (I have tried).

现在,如果您已经将功能分支相互合并,您将很难将它们分别合并到主线中。这并非完全不可能,但肯定很麻烦(我已经尝试过)。

If your feature branches contain major code churns, or if they overlap significantly with regard to the areas of code that is being worked on, you may even want to take this idea further, and have branches that integrate two features before merging them anywhere else, including the global integration branch, i. e. have multiple levels of integration. Of course, this is generally not a desirable situation, but you may not be able to avoid it, and the resulting conflicts can be a lot easier to resolve if you are generous with integration branches.

如果您的功能分支包含主要的代码改动,或者如果它们与正在处理的代码区域显着重叠,您甚至可能想要更进一步地考虑这个想法,并在将它们合并到其他任何地方之前拥有集成两个功能的分支,包括全球整合分支,即有多个整合层次。当然,这通常不是可取的情况,但您可能无法避免它,如果您对集成分支慷慨解囊,那么由此产生的冲突会更容易解决。

回答by CodingWithSpike

One major reason i often see for the need for an "integration" branch is when your feature branches are untestable on their own. In my experience, this usually is due to a database dependency. Or, consider a website project that is database backed... lets say its a JSP application hosted in BEA Weblogic, back by a 60GB Oracle database; It would take a LOT of hardware to give each feature branch its own BEA Weblogic and Oracle instance to test from. Instead, it is generally easier to develop as best as possible into a feature branch, but move into an integration branch for full QA testing, where QA needs to be performed on a full web server and database.

我经常看到需要“集成”分支的一个主要原因是当您的功能分支无法单独测试时。根据我的经验,这通常是由于数据库依赖性造成的。或者,考虑一个由数据库支持的网站项目……假设它是一个托管在 BEA Weblogic 中的 JSP 应用程序,由一个 60GB 的 Oracle 数据库提供支持;需要大量硬件才能为每个功能分支提供自己的 BEA Weblogic 和 Oracle 实例以供测试。相反,将尽可能最好地开发到功能分支通常更容易,但移动到集成分支进行完整的 QA 测试,其中 QA 需要在完整的 Web 服务器和数据库上执行。