GitHub Flow
In this page:
git switch -c branch-name
git add file_name
git commit -m "message"
git push -u origin branch-name
# then open a pull request and merge into main
What is GitHub Flow
GitHub Flow is a lightweight branching model built around a single long-lived main branch and short-lived feature branches -- unlike GitFlow's multiple permanent branches (develop, release, hotfix), GitHub Flow deliberately keeps only one permanent branch to minimize process overhead for teams that deploy continuously.
Example: What is GitHub Flow
git checkout main
git checkout -b add-search
Branch From Main
Every piece of work -- a feature, a fix, an experiment -- gets its own descriptively-named branch cut directly from main, with no intermediate develop branch to merge through first.
Example: Branch From Main
git checkout main
git checkout -b fix-header-bug
Open a Pull Request Early
GitHub Flow encourages opening a pull request as soon as a branch exists, even before the work is complete -- the PR becomes a running conversation thread for feedback, CI results, and progress visibility, not just a final review gate.
Example: Open a Pull Request Early
git push -u origin fix-header-bug
# open a pull request immediately, even before work is complete
Merge and Deploy
Once a pull request is reviewed and its checks pass, it's merged directly into main -- and because main is meant to always be deployable in this model, that merge is typically followed immediately by an automatic or one-click deployment to production.
Example: Merge and Deploy
git checkout main
git merge fix-header-bug
git push origin main
GitHub Flow vs GitFlow
GitHub Flow trades GitFlow's structured release/hotfix branches for simplicity: there's no separate develop branch to keep in sync, and no scheduled release branch -- every merge to main is a potential deploy, which suits teams practicing continuous delivery far better than GitFlow's more deliberate, versioned release cadence.
Example: GitHub Flow vs GitFlow
git checkout -b feature-x main
# merges straight to main, no develop branch
- Committing directly to
maininstead of creating a branch first, which bypasses review. - Naming branches vaguely like
fixortest, when descriptive names such asadd-searchshow the purpose. - Leaving a branch open for weeks, so
mainmoves on and the merge becomes hard; keep branches short-lived.
- Branches let you work on separate lines of development, and you create and change them with
git branch,git checkout, andgit switch. git merge,git rebase, andgit cherry-pickbring changes together.- Branch strategies and GitHub Flow describe how teams organize branches.
Chapter Quiz — Complete all 9 topics to unlock
0/9 topics done
Complete these topics first: