Team workflows · lesson 1 of 6
Commands and ideas in this lesson
AGitHub Flowmain, plus short branches through pull requests
BTrunk-basedeveryone on main, in small steps
CGit Flowdevelop, release and hotfix branches
DFeature flagunfinished work, merged but switched off

Branching models

Last updated

Every team decides how branches are used: how long they live, where work goes, how releases are made. The common recipes have names: GitHub Flow, trunk-based development, Git Flow. In this lesson you'll see the same month of Kusina work in each, and learn which suits which kind of team.

By the end of this lesson you can

  • Describe GitHub Flow, trunk-based development and Git Flow
  • Explain feature flags and why trunk-based teams use them
  • Choose a model for a team, with a reason

GitHub Flow

The simplest common model, and the one this course has used:

  1. main is always in a good state: printable, deployable.
  2. For each change, make a short branch from main.
  3. Commit, push, open a pull request, get it reviewed (and checked, lesson 7.3).
  4. Merge to main, and delete the branch. Release from main, often.

A month of Kusina in GitHub Flow: a few short loops off one line.

GitHub Flow
*   Merge pull request #9 from carla/add-palabok
|\
| * Add pancit palabok recipe
|/
*   Merge pull request #8 from ana/fix-flan-eggs
|\
| * Use 12 egg yolks in the leche flan
|/
*   Merge pull request #7 from joaquin/index-desserts
|\
| * Include the desserts folder in the index
| * List recipes in alphabetical order
|/
* Add halo-halo recipe

Trunk-based development

Everyone integrates into one branch, the trunk (main), at least once a day: either committing straight to it, or through branches that live a day or two at most. Changes are small, and automated checks run on every one.

What about a feature that takes three weeks? It's merged bit by bit, switched off behind a feature flag: a setting in the code that hides it until it's finished. The code is in main the whole time, so nobody's branch drifts far, and conflicts stay small.

Trunk-based
* Show the photo gallery (flag on)
* Use 12 egg yolks in the leche flan
* Gallery: add captions (flag off)
* Add pancit palabok recipe
* Gallery: first version, behind a flag (flag off)
* Include the desserts folder in the index

trunkbaseddevelopment.com describes it in full. Many large companies work this way, along with continuous integration (Simple Software Development 7.2).

Git Flow, and its author's note

Git Flow (Vincent Driessen, 2010) uses two long-lived branches and three kinds of short ones:

  • main: only released versions, each tagged;
  • develop: where finished features gather for the next release;
  • feature/… branches from develop; release/… branches to prepare a release; hotfix/… branches from main for urgent fixes, merged into both.
Git Flow
*   (main, tag: v1.1) Merge branch 'release/1.1'
|\
| *   (develop) Merge branch 'feature/palabok' into develop
| |\
| | * Add pancit palabok recipe
| |/
| * Bump version to 1.1
|/
*   (tag: v1.0.1) Merge branch 'hotfix/flan-eggs'
|\
| * Use 12 egg yolks in the leche flan
|/
* (tag: v1.0) Release 1.0

It suits software released as numbered versions that must be supported side by side, like apps in a store. In 2020 Driessen added a note to his article: for software that's delivered continuously, like most websites, he recommends a much simpler workflow such as GitHub Flow instead.

Release branches

Any model can add release branches: when a version is ready, branch release-1 from main, and fix only bugs on it (often by cherry-picking fixes from main, as in lesson 6.6). main carries on with new work. Kusina's printed edition, in 6.6, used one.

Which one?

Branching models compared
GitHub FlowTrunk-basedGit Flow
Long-lived branchesmainmainmain and develop
How long branches liveDaysHours to a day or twoDays to weeks
ReleasesFrom main, oftenFrom main, often (or release branches)release/ branches, tagged on main
SuitsMost teams, websites, small projectsTeams with strong automated checks, deploying many times a dayNumbered versions supported side by side
NeedsReviews and a working mainFeature flags, CI, discipline about small changesEveryone knowing the rules for five kinds of branch

Spot the trap: Git Flow for two people

Spot the trapAna

Ana reads about Git Flow and sets it up for Kusina: develop, feature branches, release branches, hotfixes. Kusina is updated whenever someone types up a recipe, and the website rebuilds from main.

What happens if…

Check what you learned

In trunk-based development, how is a three-week feature handled?
What did Git Flow’s author say about it in 2020?
In GitHub Flow, what must always be true of main?

Sources

Every command on this page behaves as these pages describe, and the sandbox prints what Git 2.55 prints. Hosting features (pull requests, protected branches) come from the host’s own documentation.

All sources for Simple Git