Lesson 12 of 15

Git Workflow Strategies

GitHub Flow

GitHub Flow is a simple workflow: main is always deployable, features go in branches, merge via pull requests.

Example
# GitHub Flow:
# 1. Create branch from main
git switch -c feature-x

# 2. Make commits
git commit -m "Add feature X"

# 3. Push and open PR
git push -u origin feature-x

# 4. Review and discuss
# 5. Merge to main
# 6. Deploy from main

Git Flow

Git Flow uses long-lived branches: main (production), develop (integration), and feature/release/hotfix branches.

Example
# Git Flow branches:
# main      — production releases
# develop   — integration branch
# feature/* — new features
# release/* — release preparation
# hotfix/*  — urgent production fixes

# Feature workflow:
git switch develop
git switch -c feature/user-profile
# ... work ...
git switch develop
git merge feature/user-profile

# Release workflow:
git switch -c release/1.2.0 develop
# ... final testing ...
git switch main
git merge release/1.2.0
git tag v1.2.0

Trunk-Based Development

Trunk-based development keeps branches short-lived and merges frequently to the main branch.

  • All developers commit to main (trunk) frequently
  • Feature branches live less than a day
  • Use feature flags for incomplete features
  • Continuous integration runs on every push
  • Simplest workflow for small, experienced teams