GitHub flow

Topic 1 of 4 in Team workflows6 min readBeginnerFree course

Overview

Every team needs agreement on how to use branches: where new work starts, how it gets reviewed and how it reaches users. This agreement is a workflow. The most widely used one is GitHub flow — simple enough to explain in a minute, and robust enough for teams of hundreds.

The rules of GitHub flow

GitHub flow: one simple branching model. main runs a1, b2, M1, c3, M2. The branch add-search (PR #12) with commits f1 and f2 starts from a1 and is merged at M1; the branch fix-footer (PR #13) with g1 and g2 starts from M1 and is merged at M2. Rules: 1, main is always deployable; 2, every change is a short-lived branch, then a PR, review and merge; 3, deploy after merging (or straight from the PR).

  1. main is always deployable. Anything on main could be released at any moment. Broken code never lands there.
  2. Every change gets its own branch from main, with a descriptive name: fix/footer-year, feature/search.
  3. Commit and push regularly to the branch — it backs up your work and shows progress.
  4. Open a pull request when you want feedback — early as a draft, or when ready for review.
  5. Review and test. Teammates review; CI runs the tests on the PR.
  6. Merge when approved and green.
  7. Deploy — many teams deploy automatically after every merge to main.
  8. Delete the branch. It’s done.

That’s the whole workflow. There’s one long-lived branch, and everything else lives for hours or days.

A cycle, command by command

Terminal
git switch main && git pull                 # start from the latest main
git switch -c feature/search                # one branch per change
# …edit, commit, repeat…
git push -u origin feature/search           # publish
gh pr create --fill                         # open the PR
# …review, CI, more commits…
git fetch && git rebase origin/main         # keep up with main if it moved
git push --force-with-lease                 # (only after a rebase)
gh pr merge --squash --delete-branch        # merge when approved
git switch main && git pull                 # back to the start

Making it work well

  • Small branches. A branch that lives two days has little to conflict with. One that lives two months becomes a merge nightmare.
  • Update from main often — rebase or merge main into your branch every day or two.
  • Automate checks. Protect main so PRs need passing tests and a review before merging (Protecting branches).
  • Hide unfinished features behind feature flags (configuration switches) so you can merge incomplete work safely, instead of keeping a branch open for weeks.
  • Deploy often. Small, frequent deploys are easier to verify and roll back.

Other workflows you’ll meet

Git Flow

An older, more elaborate model, popular for software released in versions (desktop apps, libraries with long support):

  • main holds only released versions, each tagged;
  • develop collects finished features for the next release;
  • feature/* branches come from and merge into develop;
  • release/* branches stabilise a version before it’s merged into main;
  • hotfix/* branches patch main urgently.

It gives tight control over releases, but it’s heavier: more long-lived branches, more merges, more chances for them to drift. Even its author now recommends something simpler for software that’s continuously delivered, like most web applications.

Trunk-based development

The opposite direction: everyone integrates into main (the “trunk”) at least once a day, through very small PRs or even direct commits with strong automated testing. Feature flags hide work in progress. It’s GitHub flow with the branch lifetime pushed to the minimum, and it’s what many high-performing teams use.

Release branches with GitHub flow

If you need to support old versions (say, security fixes for 1.x while 2.x is current), add release branches to GitHub flow: create release/1.x from the 1.0 tag, and cherry-pick fixes onto it from main (Cherry-picking).

Choosing

Situation Workflow
Web app or service, deployed continuously GitHub flow or trunk-based
Library or app with versioned releases GitHub flow + tags (+ release branches if you support old versions)
Strict, scheduled releases with long stabilisation Git Flow
Solo project GitHub flow — branches and PRs still help you review your own work

Start simple. GitHub flow covers most projects. Add process only when you feel a real problem it solves.

Exercise

Run GitHub flow end to end

Using a local bare repository as the shared server, run two complete GitHub flow cycles for two developers. Asha builds feature/search while Ben builds fix/footer. Each pushes their branch; Ben’s “pull request” is merged first (simulate the merge button with git merge --no-ff on main and a push). Asha then updates her branch from the new main by rebasing, pushes with --force-with-lease, and her change is merged. Delete both remote branches. main must end with both merge commits and the server must have only main.

Terminal
git init -q --bare -b main server.git
git clone -q server.git asha 2>/dev/null && cd asha
echo "<footer>(c) 2025</footer>" > footer.html && git add . && git commit -qm "Start site" && git push -qu origin main
cd .. && git clone -q server.git ben

# 1. Asha: branch, commit, push

# 2. Ben: branch, commit, push

# 3. "Merge Ben's PR" (merge commit on main, push, delete his remote branch)

# 4. Asha: update her branch from main, force-push safely

# 5. "Merge Asha's PR" and clean up

Summary

  • GitHub flow: main is always deployable; every change happens on a short-lived branch merged through a pull request.
  • Create a branch, commit, push, open a PR, review and test, merge, deploy, delete the branch — repeat.
  • Keep branches small and short-lived, and update them from main often, to avoid painful merges.
  • Git Flow adds long-lived develop and release branches — useful for versioned software with scheduled releases.
  • Trunk-based development takes GitHub flow further: tiny branches merged at least daily, with feature flags.