简体   繁体   中英

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.

在此处输入图像描述

To perform task B ideally, you should do tasks like this image.

在此处输入图像描述

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. 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.

在此处输入图像描述

Branch B implicitly includes A1, and if there is a bug, it develop transfers.

That seems inevitable if A and B are so interlinked.
If there is a bug in A, you will need to merge or cherry-pick it to B (created from A).

But for highly-coupled tasks like A and B... I would create only one branch ABui, and one 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. 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. Until then you can work on feature C.
  3. If A can't be released without B then develop both in a single branch.

You tagged your question with GitFlow - it usually implies a lot of unnecessary branches. Just so that you're aware - GitFlow is an outdated branching strategy . 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

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. 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.

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.

As those bugs are fixed on A1, you can merge branch A1 into branch B.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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