Skip to content

Instantly share code, notes, and snippets.

@whatupfoo
Last active August 28, 2024 17:07
Show Gist options
  • Save whatupfoo/5aee13041f135b04790ade03b36f8af3 to your computer and use it in GitHub Desktop.
Save whatupfoo/5aee13041f135b04790ade03b36f8af3 to your computer and use it in GitHub Desktop.

Git Flow

gitflow

Read more about this workflow here

Key Features

  • Two main long-living branches: main and develop
  • Feature branches (or sometimes called topic branches) are used to develop new features for the upcoming or a distant future release. The essence of a feature branch is that it exists as long as the feature is in development, but will eventually be merged back into develop.
  • Release branches support preparation of a new production release. The key moment to branch off a new release branch from develop is when develop (almost) reflects the desired state of the new release. At least all features that are targeted for the release-to-be-built must be merged in to develop at this point in time.
  • When the state of the release branch is ready to become a real release, it is merged into main and tagged. Finally, the changes made on the release branch need to be merged back into develop, so that future releases also contain these bug fixes.
  • When a critical bug in a production version must be resolved immediately, a hotfix branch may be branched off from the corresponding tag on the main branch that marks the production version.

Food for thought based on blog author's update in March 2020

Screen Shot 2022-02-09 at 9 47 42 AM

GitHub Flow

github-flow

Read more about this workflow here

Key Features

  • One long-living branch: main where steady, production-ready code lives.
  • Feature branches are short-lived. Deployments are typically done in Pull Request before merge.

Backport flow

backport-flow

  • Multiple branches are created for each version
  • Features and bug fixes can be selectively cherry-picked onto version branches from main branch
  • When the versions are deprecated, the version branch can be discarded and does not need to be merged back into main

Comparison

Git Flow GitHub Flow Backport Flow
Useful for release based development where a batch of changes needs to go through a set of validations and tests before a new release is published (e.g. packaged software) Useful for continuous deployments (multiple per week or day) (e.g. for web applications and services) For software that is deployed to the cloud while also shipped as an installable software, a backport flow could be a great workflow.
Helpful when compute resources are limited, e.g. long build and test times More light-weight and simpler than Git Flow Great for supporting multiple parallel versions at a time

Git Branching Strategy

Branches are cheap and fast

  • Fast parallel development and experimentation

Keep your branches close to the main branch

  • Further branches divert, the more likely merge conflicts happen
  • Merge your feature branches as soon as possible into the main branch
  • A powerful technique for allowing this rapid merging is feature flags
  • Update your branches with the latest changes from your main branch

Small branches

  • Reviewing your pull requests easier and faster
  • Small topic branches will get merged faster
  • Push early and often
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment