Git Workflows
01 / 02

Branching Models

Branching Models

Git Flow

Long-lived develop and main branches, plus feature/, release/, and hotfix/ branches following strict rules. Suits scheduled, versioned releases with multiple versions in production; often too heavyweight for teams practicing continuous deployment.

git checkout -b feature/user-auth develop
# ...work, commit...
git checkout develop && git merge --no-ff feature/user-auth

# Preparing a release — freeze feature work, bugfix/version-bump here
git checkout -b release/1.2.0 develop
# ...final fixes...
git checkout main && git merge --no-ff release/1.2.0 && git tag v1.2.0
git checkout develop && git merge --no-ff release/1.2.0   # carry fixes back

# Urgent production fix — branch directly off main
git checkout -b hotfix/critical-bug main
# ...fix, test...
git checkout main && git merge --no-ff hotfix/critical-bug && git tag v1.2.1
git checkout develop && git merge --no-ff hotfix/critical-bug  # don't forget this!

GitHub Flow

A simplified alternative: branch off main for any change, open a PR, review, merge, deploy — main is always deployable. No develop branch, no release branches. Fits teams practicing continuous deployment where every merge to main can go live.

git checkout main && git pull
git checkout -b feature/add-search
# ...commit, push...
git push -u origin feature/add-search
# Open a PR against main. CI runs. Reviewer approves. Merge (often squash).
# main is deployed — often automatically on every merge.

Trunk-Based Development

Developers integrate small, frequent changes directly into one shared trunk, often hiding unfinished work behind feature flags rather than long-lived branches. The shorter a branch lives, the less painful its eventual merge — this pairs naturally with continuous integration.

// Merge unfinished work safely — hide it behind a flag until ready
if (featureFlags.isEnabled('new-checkout-flow', user)) {
  return renderNewCheckout();
}
return renderLegacyCheckout();

// This decouples "merge to main" from "release to users" — flip the flag
// for a subset of users, or roll back instantly, with no Git history change.

Keep your own version of these notes — editable, searchable, and organised by your stack.

Start free