Engineering Craft › Branching & Releases
GitHub Flow
Branch from main, open a PR, merge back to main.
Also known as: GitHub flow, GitHub workflow, pull request workflow
GitHub flow is a simple branching workflow built around pull requests. main is always deployable, and everything else happens on short-lived branches.
- Branch from
mainwith a descriptive name. - Commit your changes, and push the branch regularly.
- Open a pull request, early if you want feedback.
- Discuss and review. Add commits in response to comments.
- Run checks (tests, linting) automatically in CI.
- Merge into
mainonce approved and green. - Deploy (often automatically) and delete the branch.
main: ──●────────────●────────────●──
\ / \ /
feature: ●──●──● ●──●──●
(PR #41) (PR #42)
Why teams like it
- Easy to learn: one long-lived branch, one rule.
- Fits continuous delivery. Because
mainis deployable, you can release often (continuous delivery). - Review is built in.
- Works well for web applications and teams that deploy continuously.
What it requires
- A trustworthy
main: CI must catch breakage, and failing changes must not merge. Use protected branches. - Small pull requests that can be reviewed and merged quickly (small PRs).
- Fast, reliable tests.
- Safe ways to ship unfinished work, such as feature flags.
Compared with others
Heavier models (Git Flow, with develop, release and hotfix branches) suit software with scheduled, versioned releases. GitHub flow suits software that ships continuously. If you ship versioned packages or mobile apps, you may need release branches too (hotfixes).
Follow whatever your team uses, and understand why.