First, I want to
- Keep my
master
branch ALWAYS green. - Be able to cherry pick changes for the next release.
Branching strategy:
- I have a
master
branch and anintegration
branch running alongside with it. - Branch off from
master
by tasks/issues. - When a task-branch finished its work, merge that into
integration
to see if it has broken any works from other task-branches. If yes, fix them. Pull request from the task-branch(not
integration
branch) tomaster
branch.That means the
integration
branch is only for CI purpose, it will NEVER be merged intomaster
- Decide which changes the next release will include. Merge those branches into
master
. - Release.
Here is the problem, let's say I have the following situation:
master -*-----------------
|\
integration -+-\-------C---F---
| \ / /
ken/task#1 | A---B /
| /
bob/task#2 D---------E
In F
, two things happen:
- A merge conflict occurs as
C
andF
have changed the same lines ofsome-code.js
F
breaks some tests fromC
.
Now, Bob has to fix that, he has 2 options:
Option 1
- Merge
integration
intobob/task#2
asG
- Fix the bugs in
H
- Merge into
integration
asI
integration
greenPull request
master -*-------------------------- |\ integration -+-\-------C---F-----------I | \ / / \ / ken/task#1 | A---B / \ / | / \ / bob/task#2 D---------E-------G---H
However, with this approach, I cannot pick only task#2
to be included in my next release.
Because bob/task#2
(H
) already contains the changes made in ken/task#1
, merging bob/task#2
into master
means merging ken/task#1
into master
together.
Option 2
- Switch back to
bob/task#2
- Try to fix the bug in
G
- Merge into
integration
and run the tests to see if the tests are green - If it doesn't, switch back to
bob/task#2
- Try to fix it in
I
Merge into
integration
and run the test...
Until
integration
is green.Pull request
master -*----------------- |\ integration -+-\-------C---F---H---J--- .......... | \ / / / / ken/task#1 | A---B / / / | / / / bob/task#2 D---------E---G---I--- ..............
This approach prevents bundling changes from ken/test#1
into bob/task#2
.
However, Bob now needs to "guess" what he needs to do to fix the bug. Then merge over and over again into integration
to see if the tests are green because G
and I
now don't have the tests added in C
.
He also needs to resolve that same some-code.js
merge conflict EVERY TIME he merges his work into integration
, which is painful and redundant.
Does Bob have a better option 3?
Thanks.