简体   繁体   English

当我需要其他分支的一些代码时如何为功能创建分支(未合并到开发分支中)

[英]How to create branch for feature when i need some code of other branch (not merged in develop branch)

There is a big challenge in doing my tasks, and that is doing interdependent tasks Which I said in this picture.做我的任务有一个很大的挑战,那就是做我在这张照片中所说的相互依赖的任务。 Suppose we have two tasks, A and B, to perform subtasks A1, A2, and B1, B2, given that task B depends on A.假设我们有两个任务 A 和 B 来执行子任务 A1、A2 和 B1、B2,假设任务 B 依赖于 A。

在此处输入图像描述

To perform task B ideally, you should do tasks like this image.要理想地执行任务 B,您应该执行类似此图像的任务。

在此处输入图像描述

But this does not happen in many cases, for example, when doing A2 work from the server and to avoid wasting time, we decided to work on task B at the same time.但这在很多情况下不会发生,例如,在服务器上做 A2 工作时,为了避免浪费时间,我们决定同时处理任务 B。 In this case, the first solution that I do not think is true is to make Branch B from A, as in the image below, which is not very correct, because Branch B implicitly includes A1, and if there is a bug, it develop transfers.在这种情况下,我认为不正确的第一个解决方案是从 A 制作分支 B,如下图所示,这不是很正确,因为分支 B 隐式包含 A1,如果有错误,它会开发转移。

在此处输入图像描述

Branch B implicitly includes A1, and if there is a bug, it develop transfers. B分支隐含A1,如果有bug,开发转移。

That seems inevitable if A and B are so interlinked.如果 A 和 B 如此相互关联,这似乎是不可避免的。
If there is a bug in A, you will need to merge or cherry-pick it to B (created from A).如果 A 中存在错误,您需要将其合并或挑选到 B(从 A 创建)。

But for highly-coupled tasks like A and B... I would create only one branch ABui, and one ABapp但是对于像 A 和 B 这样的高度耦合的任务......我只会创建一个分支 ABui 和一个 ABapp

Branching from feature branches is a good indicator of messy process .从特征分支分支是混乱过程的一个很好的指标 Sometimes it's inevitable, but each time you have to think about other solutions:有时这是不可避免的,但每次您都必须考虑其他解决方案:

  1. Push A to master (or develop if that's your main branch) even if it's not ready.将 A 推到 master (或者如果那是你的主分支,则进行开发),即使它还没有准备好。 But hide the changes from user via Branching by Abstraction or Feature Toggles.但是通过抽象分支或功能切换隐藏用户的更改。
  2. Consider re-prioritizing so that feature B isn't started until A is merged.考虑重新确定优先级,以便在合并 A 之前不会启动功能 B。 Until then you can work on feature C.在此之前,您可以处理功能 C。
  3. If A can't be released without B then develop both in a single branch.如果没有 B 就无法发布 A,那么在一个分支中开发两者。

You tagged your question with GitFlow - it usually implies a lot of unnecessary branches.你用 GitFlow 标记了你的问题——它通常意味着很多不必要的分支。 Just so that you're aware - GitFlow is an outdated branching strategy .只是让您知道-GitFlow 是一种过时的分支策略 It's only applicable when you maintain multiple versions of the product at the same time.仅当您同时维护产品的多个版本时才适用。

to avoid wasting time, we decided to work on task B at the same time为了避免浪费时间,我们决定同时处理任务 B

While you think you don't waste time by starting to work on B - you may end up wasting more time because of the parallel work.虽然您认为开始在 B 上工作不会浪费时间,但您最终可能会因为并行工作而浪费更多时间。 Modern dev processes (Just-in-time, Theory of Constraints, Continuous Delivery) teach us to have small amount of unfinished work (aka Inventory Costs) - the smaller the better.现代开发流程(即时、约束理论、持续交付)告诉我们有少量未完成的工作(也称为库存成本)——越小越好。 By branching too much and having a lot of unreleased code you increase the amount of unfinished work which increases the costs of development.通过分支过多并拥有大量未发布的代码,您会增加未完成工作的数量,从而增加开发成本。

given that task B depends on A.假设任务 B 依赖于 A。

This implies that B will have all the bugs you write in task A. There's no way to avoid that if this dependency holds.这意味着 B 将拥有您在任务 A 中编写的所有错误。如果这种依赖关系成立,则无法避免这种情况。

As those bugs are fixed on A1, you can merge branch A1 into branch B.由于这些错误已在 A1 上修复,您可以将分支 A1 合并到分支 B。

暂无
暂无

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

相关问题 如何停止与开发分支合并的分支与主分支合并? - How to stop a branch merged with develop branch to be merged with master branch? 当我使用GitFlow时,为什么需要将发布分支合并到develop分支中? - Why does the release branch need to be merged into develop branch when I use GitFlow? git:我不小心将功能分支合并到master中,而不是进行合并 - git: I accidentally merged feature branch into master instead of develop 当我们在其他分支中合并一个分支时,则本地分支被合并或远程分支被合并 - when we merge a branch in some other branch, then either local branches are merged or remote branch merged 检查develop分支是否已合并到功能分支中? - Checking if develop branch has been merged into feature branch? 如何使功能分支与开发分支同步? - How to bring feature branch in sync with develop branch? 将功能分支与开发分支同步 - Sync feature branch with develop branch Git:如何将分支功能重新建立到分支开发基础上减去分支MyLocalChanges - Git: How do I rebase Branch Feature back onto Branch Develop minus Branch MyLocalChanges 问题将Git Feature分支合并到“Beta”分支(在它已经合并到“Develop”分支之后) - Issue merging Git Feature branch into “Beta” branch (after it has already been merged to “Develop” branch) 父分支在子分支之前合并开发的情况如何处理? - How to deal with the situation that the parent branch was merged to develop before a child branch?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM