Skip to content

Branching Strategies (GitHub Flow · Git Flow · Versioning) ​

This page centers on GitHub Flow, compares it with other branching strategies such as Git Flow, and then covers versioning strategies for releases.

GitHub Flow ​

GitHub Flow is a simple and clear branching strategy proposed by GitHub. Its core idea is just one thing:

The main (or master) branch is always kept in a deployable state.

Feature branches ​

For each new feature or fix, you create a separate branch, work on it, and merge it into the main branch when you are done. Multiple features can be developed independently, and conflicts are minimized even when several people work at the same time.

Workflow ​

  1. Create a new branch from the main branch
  2. Work on the branch
  3. Open a Pull Request
  4. Code review
  5. Merge

How do we guarantee "always deployable"? ​

Two safeguards are needed.

  1. Code review: people catch errors with their own eyes before merging. But since humans do it, some things will inevitably slip through.
  2. Tests (automated CI): the branch is checked out, built and tested automatically, so it is already confirmed as "deployable" before review.

Problems you run into in practice ​

When the structure keeps changing early in a project: if the team's design patterns are not settled yet and everyone writes code differently, clashes in methodology quickly turn into code conflicts. In this case it is better to first get together and agree on direction and rules, or have one person quickly validate the structure with a prototype, and then adopt GitHub Flow.

When the size of a feature is unclear: "what counts as one feature" differs by company, project and person. These criteria help:

  • Define it concretely (e.g. "change the login button design" instead of "improve the UI")
  • It should be deployable independently
  • At deployment time it should be compatible with other code without conflicts
  • It should be a reasonable size, neither too big nor too small

Git Flow vs GitHub Flow, and Other Strategies ​

Why two separate strategies emerged ​

In the early 2010s, software was released on fixed cycles, and big updates needed a long preparation period. CI was still in its early days and CD (continuous delivery) had not become mainstream yet. So Git Flow appeared: a complex model with master and develop at the center, broken down further into feature, release and hotfix branches. It was a tool for systematically managing periodic releases and sudden hotfixes.

Over time, as CI/CD matured, release frequency increased dramatically (some companies now deploy several times a day). This environment called for a simpler model rather than complex branching, and so GitHub Flow, which uses only main + feature branches, gained attention.

Comparison ​

GitHub FlowGit Flow
Branch structuremain + featuremaster, develop, feature, release, hotfix
Good forSimple, fast development, always shipping the latest versionManaging multiple versions at once, when complex and systematic management is needed
Typical exampleWeb services that update frequentlyLibraries that must support past versions, B2B software for many companies

GitLab Flow: a compromise between the two ​

GitLab Flow mixes the strengths of GitHub Flow and Git Flow and is optimized for CI/CD environments. In addition to main and feature, it uses environment branches. Besides production, where the real service runs, and develop, which is under development, extra environments such as QA and stage each get their own branch, and the CI/CD pipeline is set up so that merging into a branch immediately deploys to that environment. It suits teams with varied deployment scenarios, but with so many branch types it has an initial learning cost and the burden of keeping branches in sync.

Trunk Based Development: extremely fast integration ​

This strategy merges almost all work into a single main (trunk) branch right away. It is similar to GitHub Flow, but the PR cycle is much shorter, so even tiny units of change that users would hardly notice are merged into main immediately.

How can an unfinished feature sit on a deployable main? The answer is a feature toggle. The feature is merged into the code but can be switched on and off so it is not exposed to users. This lets you enjoy the benefits of continuous integration while hiding unfinished features. It brings the burden of committing and testing often, but it keeps the codebase from drifting apart and lowers deployment risk.

Versioning Strategy: Semantic Versioning ​

SemVer: MAJOR.MINOR.PATCH ​

Semantic Versioning (SemVer) is the most widely used versioning scheme. It consists of three numbers: MAJOR.MINOR.PATCH.

  • MAJOR: big changes that break compatibility (API changes, full redesigns, etc.)
  • MINOR: compatible new features
  • PATCH: compatible bug fixes

For example, 1.5.3 means "since 1.0.0, compatible features were added 5 times, and bugs were fixed 3 times along the way."

Pre-release: written after a hyphen, like 1.0.0-alpha, to mark unstable versions such as alpha/beta/RC. It is ordered lower than the official release. Build metadata: appended after +, like 1.0.0+build20240101. It is extra information that does not affect version precedence.

Date-based Versioning ​

This scheme uses dates instead of numbers for versions. Example: Ubuntu's 20.04 LTS (released in April 2020). The advantage is that you can see right away when it came out, but the drawback is that you cannot tell the size or importance of the changes.

Versioning on GitHub ​

Git manages versions with Tags, and GitHub adds support for writing release notes and downloading compressed source code. In the Releases tab, click Create a new release, enter a tag, and click Generate release notes; GitHub collects the PR titles since the last release and builds the release notes automatically. Simply writing good PR titles means maintenance documentation accumulates by itself.

Summary ​

ConceptOne-line summary
GitHub FlowKeep main always deployable, run simply with feature branches + PRs
Git Flow / GitLab Flow / Trunk BasedComplex version management (Git Flow), CI/CD-focused environment separation (GitLab Flow), extremely fast integration (Trunk Based)
Semantic VersioningEncodes the size and compatibility of changes in the version number as MAJOR.MINOR.PATCH

Source: Codyssey-B1/B2-2