Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Last updated: Monday 09 November 2026 @ 12:56:44

Git OneFlow

Git · Branching strategies

Git OneFlow

Explore a branching model centred on one permanent mainline, with temporary feature, release and hotfix branches.

OneFlowFeature branchesRebaseReleasesHotfixes
One permanent branch

Explain why OneFlow retains a single long-lived integration branch.

Integrate features

Compare rebase, --no-ff merge and a combined strategy.

Manage releases

Use a temporary release branch and tags to identify published versions.

OneFlow in context

OneFlow is an alternative to the more elaborate GitFlow branching model. The central idea is a single long-lived mainline, named main in this practical, accompanied by short-lived support branches. Tags identify releases; release and hotfix branches are created only when needed.

OneFlow is most useful where new releases build upon earlier versions. When several incompatible versions need long-term maintenance, separate maintenance lines may still be necessary. Fast-moving continuously deployed systems may not need dedicated release branches at all.

A feature branch created from a common mainline

Features are developed separately before integration.

Practical: establish the mainline

  1. Create an empty repository with a mainline and an initial release.

    mkdir -p ~/git-oneflow-lab && cd ~/git-oneflow-lab
    git init -b main
    git config user.name "Git Student"
    git config user.email "student@example.invalid"
    printf 'Sensor monitor v1\n' > app.txt
    git add app.txt
    git commit -m "feat: initial sensor monitor"
    git tag v1.0.0
  2. Create a feature branch and commit new functionality.

    git switch -c feature/adc
    printf 'ADC conversion enabled\n' > adc.txt
    git add adc.txt
    git commit -m "feat: add ADC description"
  3. Inspect the repository graph and determine which commit the release tag identifies.

    git log --all --oneline --graph --decorate
    git show --stat v1.0.0

Option 1: rebase and fast-forward

  1. Make a separate commit on main so the feature and mainline have diverged.

    git switch main
    printf 'Project uses short-lived feature branches.\n' > CONTRIBUTING.md
    git add CONTRIBUTING.md
    git commit -m "docs: define branch workflow"
  2. Rebase the unpublished feature onto the current main.

    git switch feature/adc
    git rebase main
  3. Fast-forward main and inspect the resulting linear graph.

    git switch main
    git merge --ff-only feature/adc
    git log --all --oneline --graph --decorate
History after rebasing and fast-forward merging a feature

A rebase can produce a linear integration history.

Option 2: merge commit

  1. Create a new feature branch, introduce a file and commit it.

    git switch -c feature/pwm
    printf 'PWM duty cycle controls average output.\n' > pwm.txt
    git add pwm.txt
    git commit -m "feat: document PWM"
  2. Create an independent commit on main to make the difference between merge strategies visible.

    git switch main
    printf 'Release policy: review changes.\n' > RELEASES.md
    git add RELEASES.md
    git commit -m "docs: add release policy"
  3. Merge the feature with an explicit merge commit and inspect the graph.

    git merge --no-ff feature/pwm -m "merge: PWM feature"
    git log --all --oneline --graph --decorate
A feature branch integrated through a merge commit

An explicit merge commit records a feature integration point.

Option 3: rebase followed by a merge commit

The third original OneFlow option first rebases a feature onto the current mainline, then integrates it with git merge --no-ff. This preserves a merge boundary even when a fast-forward would otherwise be possible. It is a team convention rather than a universal requirement.

Feature rebased before integration with a merge commit

Rebasing and a merge commit can be combined.

Release branches

Release branches provide a place to stabilise a selected feature set while other development continues on main. A release branch is temporary; the tag identifies the published commit.

  1. Create a release branch at the current mainline.

    git switch main
    git switch -c release/v1.1.0
  2. Apply a release-only correction and commit it.

    printf 'Release v1.1.0: ADC and PWM notes.\n' > CHANGELOG.md
    git add CHANGELOG.md
    git commit -m "docs: prepare v1.1.0 notes"
  3. Integrate the release branch back into main, tag it and inspect its content.

    git switch main
    git merge --no-ff release/v1.1.0 -m "merge: release v1.1.0"
    git tag v1.1.0
    git show --stat v1.1.0
  4. Delete the temporary local release branch after confirming the tag exists.

    git tag --list
    git branch -d release/v1.1.0
Release branch returning to the mainline

Release branches are temporary; the release tag remains.

Hotfixes

A hotfix starts from the version that actually needs repairing. If production uses the most recent tag on main, a short-lived hotfix branch can be integrated into main and followed by a patch release. Older supported releases may need their own maintenance branches.

  1. Create a hotfix branch from main and correct the sample application text.

    git switch main
    git switch -c hotfix/sensor-label
    printf 'Sensor monitor v1.1 (label verified)\n' > app.txt
    git add app.txt
    git commit -m "fix: clarify monitor label"
  2. Integrate and tag the patch release.

    git switch main
    git merge --no-ff hotfix/sensor-label -m "merge: sensor label fix"
    git tag v1.1.1
    git log --all --oneline --graph --decorate
  3. Confirm the difference between the two release tags.

    git diff --stat v1.1.0..v1.1.1
    git diff v1.1.0..v1.1.1 -- app.txt
Hotfix branch integrated into the OneFlow mainline

A patch release identifies the repaired state.

Choosing an integration strategy

StrategyHistoryTrade-off
Rebase + fast-forwardLinearRewrites unpublished feature commit IDs
Merge --no-ffExplicit branch boundaryMore merge commits
Rebase + merge --no-ffUpdated commits plus merge boundaryRequires careful team coordination

Further reading