Git OneFlow
Git OneFlow
Explore a branching model centred on one permanent mainline, with temporary feature, release and hotfix branches.
Explain why OneFlow retains a single long-lived integration branch.
Compare rebase, --no-ff merge and a combined strategy.
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.

Features are developed separately before integration.
Practical: establish the mainline
-
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 -
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" -
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
-
Make a separate commit on
mainso 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" -
Rebase the unpublished feature onto the current
main.git switch feature/adc git rebase main -
Fast-forward
mainand inspect the resulting linear graph.git switch main git merge --ff-only feature/adc git log --all --oneline --graph --decorate

A rebase can produce a linear integration history.
Option 2: merge commit
-
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" -
Create an independent commit on
mainto 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" -
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

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.

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.
-
Create a release branch at the current mainline.
git switch main git switch -c release/v1.1.0 -
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" -
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 -
Delete the temporary local release branch after confirming the tag exists.
git tag --list git branch -d release/v1.1.0

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.
-
Create a hotfix branch from
mainand 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" -
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 -
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

A patch release identifies the repaired state.
Choosing an integration strategy
| Strategy | History | Trade-off |
|---|---|---|
| Rebase + fast-forward | Linear | Rewrites unpublished feature commit IDs |
Merge --no-ff | Explicit branch boundary | More merge commits |
Rebase + merge --no-ff | Updated commits plus merge boundary | Requires careful team coordination |