4 branching workflows for Git

In this article, we will cover the most popular branching workflows for Git users, so you can decide which fits better to your own development cycle.

Git Flow

  • master — this branch contains production code. All development code is merged into master in sometime.
  • develop — this branch contains pre-production code. When the features are finished then they are merged into develop.

During the development cycle, a variety of supporting branches are used:

  • feature-* — feature branches are used to develop new features for the upcoming releases. May branch off from develop and must merge into develop.
  • hotfix-* — hotfix branches are necessary to act immediately upon an undesired status of master. May branch off from master and must merge into master anddevelop.
  • release-* — release branches support preparation of a new production release. They allow many minor bug to be fixed and preparation of meta-data for a release. May branch off from develop and must merge into master anddevelop.

Advantages

  • The branches naming follows a systematic pattern making it easier to comprehend
  • It has extensions and support on most used git tools
  • It is ideal when there it needs to be multiple version in production

Disadvantages

  • The master/develop split is considered redundant and makes the Continuous Delivery and the Continuos Integration harder
  • It isn’t recommended when it need to maintain single version in production

GitHub Flow

  1. Anything in the master branch is deployable
  2. To work on something new, create a branch off frommaster and given a descriptively name(ie: new-oauth2-scopes)
  3. Commit to that branch locally and regularly push your work to the same named branch on the server
  4. When you need feedback or help, or you think the branch is ready for merging, open a pull request
  5. After someone else has reviewed and signed off on the feature, you can merge it into master
  6. Once it is merged and pushed to master, you can and should deploy immediately

Advantages

  • A simpler alternative to Git Flow
  • It is ideal when it needs to maintain single version in production

Disadvantages

  • Are not adequate when it needs the release plans
  • It doesn’t resolve anything about deploy, environments, releases, and issues
  • It isn’t recommended when multiple versions in production are needed

GitLab Flow

The GitLab Flow is based on 11 rules:

  1. Use feature branches, no direct commits on master
  2. Test all commits, not only ones on master
  3. Run all the tests on all commits (if your tests run longer than 5 minutes have them run in parallel).
  4. Perform code reviews before merges into master, not afterwards.
  5. Deployments are automatic, based on branches or tags.
  6. Tags are set by the user, not by CI.
  7. Releases are based on tags.
  8. Pushed commits are never rebased.
  9. Everyone starts from master, and targets master.
  10. Fix bugs in master first and release branches second.
  11. Commit messages reflect intent.

Advantages

Disadvantages

  • It can become complex as Git Flow when it needs to maintain multiple version in production

One Flow

Advantages

Disadvantages

  • The feature branches make it harder the Continuos Integration
  • It isn’t recommended when it needs to maintain single version in production

Conclusion

References

Software Developer at Loft

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store