First, I want to
master
branch ALWAYS green.Branching strategy:
master
branch and an integration
branch running alongside with it.master
by tasks/issues.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) to master
branch.
That means the integration
branch is only for CI purpose, it will NEVER be merged into master
master
.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:
C
and F
have changed the same lines of some-code.js
F
breaks some tests from C
.Now, Bob has to fix that, he has 2 options:
Option 1
integration
into bob/task#2
as G
H
integration
as I
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
bob/task#2
G
integration
and run the tests to see if the tests are greenbob/task#2
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.
You should considering following the Git flow:
https://www.atlassian.com/git/tutorials/comparing-workflows
Here are my thoughts on how you can align with Git flow development model:
When the pre-release branch is ready for production merge the pre-release branch back into the master branch (this will be a fast-forward merge) and at the same time merge the same branch into Integration. Take this opportunity to squash the commits into a single commit so that you have a cleaner commit history on master.
After you've merged into the integration or master branch, clean up your branches: delete the dev branch after merging into integration; delete the pre-release branch after merging into master.
Tag production releases using a semantic versioning strategy. Create an official release branch to support fixes going forward.
When you identify an issue on the release branch, follow the same process to fix the issue as you would for developing new features (steps 1-5). Make fixing on the master branch a priority over fixing the issue on the release branch. Once fixed, cherry-pick the fix onto the release branch.
The strategy for a hot fix is different. For a hot fix, apply the fix from a branch off of master, and cherry-pick the fix onto the Integration branch.
To summarize, the main points that I would recommend is:
Git Flow is well-suited for medium to large-scale projects. But I actually prefer GitHub Flow for smaller projects, especially if I'm developing component libraries for the web.
Learn more about it here: http://scottchacon.com/2011/08/31/github-flow.html