admin管理员组文章数量:1394759
The problem:
- I receive a task
task-a
- I create a new branch
task-a-branch
based ondev
branch to work ontask-a
- I finish working on
task-a
and create a pull request fromtask-a-branch
todev
- I then have
task-b
to work on and I can't wait for someone to review and complete the PR fromtask-a-branch
todev
task-b
happens to be dependent on the work I did ontask-a
, so I can't create a new branchtask-b-branch
based ondev
- I have no choice but to make
task-b-branch
based ontask-a-branch
to work ontask-b
- Everything is sort of fine until I finish working on
task-b
and now I need to create a PR fromtask-b-branch
todev
At this point the problem isn't really a major one, but some silliness ensues. I often comment on the task-b-branch
PR that task-a-branch
should be merged first as this one is continuation on that and while all of this technically works, it:
- Feels weird for
task-b-branch
and the related PR to include everything intask-a-branch
and it's related PR task-b-branch
is probably a bit weird to review, as it doesn't just containtask-b
changes, but alsotask-a
changes- Git (e.g. Gitlab) shows changes and diffs unrelated to
task-b
when looking at thetask-b-branch
PR - It feels inherently wrong or awkward to have (small) task/feature branches depend on each other
- If, say, we had a couple of testers who did manual testing, the one who takes on the task to test
task-b-branch
cannot test it in isolation
To visualize this:
Dependent case (problematic)
Independent case (no problems)
The ideal scenario is when the task-a
and task-b
are independent of each other. Both task-a-branch
and task-b-branch
can be created based on dev
, both branches can be merged in any order and both branches PR's contain only isolated changes.
Some thoughts
I wonder if this is really a GIT issue even? In certain cases this issue can be solved by simply merging the task-a
and task-b
into one task and working on both in, say, task-a-and-task-b-branch
. This seems to be a good solution when the tasks are closely related to each other.
However, there are times when maybe task-a
has something to do with e.g. how the front end fetches things from somewhere (maybe it's about updating/refactoring the API communication process in general) and task-b
is some simple new feature where we fetch some stuff somewhere and show it in a table. In this case task-a
and task-b
are unrelated in a task/feature sense, but as task-a
makes changes to front end's API communication process which task-b
utilizes, task-b
is still dependent on task-a
.
So what would be a good way to handle such situations? Is there some GIT magic that could be done to e.g. filter out changes in task-a-branch
when looking at task-b-branch
for review etc.? Is it ever a good idea to have dependent branches like this? Or is this whole thing symptom of broken development process?
The problem:
- I receive a task
task-a
- I create a new branch
task-a-branch
based ondev
branch to work ontask-a
- I finish working on
task-a
and create a pull request fromtask-a-branch
todev
- I then have
task-b
to work on and I can't wait for someone to review and complete the PR fromtask-a-branch
todev
task-b
happens to be dependent on the work I did ontask-a
, so I can't create a new branchtask-b-branch
based ondev
- I have no choice but to make
task-b-branch
based ontask-a-branch
to work ontask-b
- Everything is sort of fine until I finish working on
task-b
and now I need to create a PR fromtask-b-branch
todev
At this point the problem isn't really a major one, but some silliness ensues. I often comment on the task-b-branch
PR that task-a-branch
should be merged first as this one is continuation on that and while all of this technically works, it:
- Feels weird for
task-b-branch
and the related PR to include everything intask-a-branch
and it's related PR task-b-branch
is probably a bit weird to review, as it doesn't just containtask-b
changes, but alsotask-a
changes- Git (e.g. Gitlab) shows changes and diffs unrelated to
task-b
when looking at thetask-b-branch
PR - It feels inherently wrong or awkward to have (small) task/feature branches depend on each other
- If, say, we had a couple of testers who did manual testing, the one who takes on the task to test
task-b-branch
cannot test it in isolation
To visualize this:
Dependent case (problematic)
Independent case (no problems)
The ideal scenario is when the task-a
and task-b
are independent of each other. Both task-a-branch
and task-b-branch
can be created based on dev
, both branches can be merged in any order and both branches PR's contain only isolated changes.
Some thoughts
I wonder if this is really a GIT issue even? In certain cases this issue can be solved by simply merging the task-a
and task-b
into one task and working on both in, say, task-a-and-task-b-branch
. This seems to be a good solution when the tasks are closely related to each other.
However, there are times when maybe task-a
has something to do with e.g. how the front end fetches things from somewhere (maybe it's about updating/refactoring the API communication process in general) and task-b
is some simple new feature where we fetch some stuff somewhere and show it in a table. In this case task-a
and task-b
are unrelated in a task/feature sense, but as task-a
makes changes to front end's API communication process which task-b
utilizes, task-b
is still dependent on task-a
.
So what would be a good way to handle such situations? Is there some GIT magic that could be done to e.g. filter out changes in task-a-branch
when looking at task-b-branch
for review etc.? Is it ever a good idea to have dependent branches like this? Or is this whole thing symptom of broken development process?
1 Answer
Reset to default 2One suggestion if it works in your anization:
When you are done with
task-a
, commit it, and ask for a merge oftask-a-branch
ondev
.Create
task-b-branch
based ontask-a-branch
, or actually (the way it works in Git) based on your last commit ontask-a-branch
, like you suggested.Finish
task-b
and commit ontask-b-branch
, but don’t ask for it to be merged yet.When your
task-a
fix has been merged intodev
, dogit rebase dev
intask-b-branch
. If there are conflicts, fix them and commit again ontask-b-branch
.Now the situation is as if you had created
task-b-branch
based ondev
after thetask-a
fix was merged. So you ask for a merge oftask-b-branch
ondev
.
本文标签: mergeHow to manage sequential dependent branches in GitStack Overflow
版权声明:本文标题:merge - How to manage sequential dependent branches in Git? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744103231a2590958.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
task-b-branch
on top oftask-a-branch
in case you make changes in task-a before it is merged. Otherwise, you do get into trouble. (But that's still not an indication of a broken workflow, but only of an inattentive developer.) – j6t Commented Mar 27 at 12:56