GitFlow is a branching model created by Vincent Driessen on 2010 (original article). Since it was published, many companies had tested and implemented it, which allows us to have many reviews about how well (or not) it works. After some discussions within our team, we decided to not go with GitFlow, but use a simpler model instead, together with a tightly defined workflow. Some of the discussed reasons of why not go with GitFlow are the same written on this blog post.
Compared to GitFlow, it is easier to implement and does not require any plugins to be properly used. The step-by-step of this model would be:
This Atlassian article have a more detailed view on the feature branch model
The squash and merge is made up of two processes: the squash, which compact all commits in one big commit/patch, and then the merge itself. After squashing + merging, you will have only one commit in the target branch (usually master) containing all your modifications. This enables two things:
There are more information about about why devs prefers squash and merge, instead of only merging, on this article.
In the feature branch model, a merge is considered a new version release. To track each release version, tags can be used. These will be used as reference to choose which version should be deployed at the servers.
To manage these tags/release, a good practice is the usage of semantic versioning:
Given a version number MAJOR.MINOR.PATCH, increment the:
1. MAJOR version when you make incompatible API changes,
2. MINOR version when you add functionality in a backwards-compatible manner, and
3. PATCH version when you make backwards-compatible bug fixes.
The process to create the releases can be automated using grunt-release or gulp-release-tasks. But, following the steps bellow, it can be easily done by hand:
In many PaaS, such as AWS Beanstalk or Heroku, a remote repository is set-up where, when changes are pushed (eg. git push heroku master), a deploy is triggered using the latest commits on master. In these cases, a simple push force using the release tag will deploy the desired version: git push -f <deploy/env-remote> v0.2.0^{}:master. Easy, eh?
NOTE: At Chaordic New Offers Team, a grunt script was developed where we publish which tag should be deployed: grunt deploy:<version>:<env>:all
At some point, an issue will be raised and the production version will need a hot-fix ASAP. A feature branch can't just be opened to develop a fix, as the master will probably be ahead of the production version. In this case, the fix needs to be done directly on the production version:
If more patches are needed, this process can be repeated on the same version, incrementing only the patch version.
<a href="https://medium.com/media/364660922d3d96660250608a21ca716a/href">https://medium.com/media/364660922d3d96660250608a21ca716a/href</a>
This patch probably should be applied to other environments as well, which can be done through git cherry-pick <commit-hash> . It basically applies the chosen commit to the actual HEAD.
It is very similar to the above one: a git cherry-pick should be done using a commit hash from the master as, after squash + merge a push request, a new commit is generated with all changes (big patch of commits condensed in one).
The gap between the environments versions should be as short as possible. Otherwise, some issues may appear:
Usually, these version gaps occur when the producing capacity is higher than the testing capacity (developers x testers ratio).
The model is still being tested but, until now, it has been working well. The only faced drawbacks were the ones pointed on the session above.