← Back to blog

September 29, 2026 · 9 min read

Mastering Git: Branching Strategies Real Teams Use

From Mid-Level to Senior · Part 2 of 18

  • #git
  • #workflow
  • #senior-engineer
  • #engineering-practices

Most engineers learn Git one command at a time. commit, push, pull, then branch and merge, then eventually rebase after something goes wrong and someone senior has to fix it. That's enough to get work done. It isn't enough to decide how a whole team should work.

A branching strategy is a team agreement, not a Git feature. It answers questions like: where does new work start? How long can a branch live? What has to be true before something reaches main? How do we ship a fix when the next release is half-built? Git will happily let you do anything. The strategy is what stops five people from doing five different things.

In Part 1 I said senior engineers are the ones who make vague problems clear. "How do we use Git here?" is a good example. On most teams nobody ever decided. It just happened, and the result is a mix of habits from everyone's previous job.

The real cost of long-lived branches

Before comparing strategies, it helps to understand the thing they're all trying to manage: divergence. The moment you branch, your copy of the code and main start drifting apart. Every day, other people merge changes you don't have, and you write changes they don't have.

The cost of bringing those two lines back together doesn't grow in a straight line. A one-day branch usually merges without anyone noticing. A two-week branch touches files that three other people also changed, and now the merge is a small project of its own.

A chart showing a main line with commits and a feature branch that drifts away from it over time. Below it, a curve of merge pain rises slowly for the first few days and then climbs steeply. Labels mark three points: after one day, a trivial merge; after one week, a few conflicts; after three weeks, a painful merge and re-testing everything. A caption says: conflicts grow with every day a branch lives.

Conflicts are only the visible part. The hidden costs are worse:

  • Late integration. Your code has never run next to everyone else's. Two changes that each pass their own tests can break when they meet.
  • Stale reviews. A 2,000-line diff gets a rubber stamp, not a review. (We'll talk about PR size properly in Part 3.)
  • Blocked teammates. Someone needs the refactor you did in week one, but it's stuck inside a branch that won't be ready until week three.

So the practical goal of almost any branching strategy is the same: keep branches short, integrate often, and have a clear rule for what goes where. The strategies differ mostly in how much structure they put around that.

The three strategies you'll actually see

Three side-by-side diagrams. Git Flow shows five lanes: main, hotfix, release, develop and feature, with feature branches merging into develop, a release branch cut from develop and merged into main with a version tag, and a hotfix going straight from main back into main and develop. GitHub Flow shows main plus short feature branches, each opened as a pull request and merged back, with every merge deployed. Trunk-based development shows a single main line with many tiny commits or branches lasting hours, and a feature flag icon hiding unfinished work.

Git Flow

Git Flow has two permanent branches, main (what's in production) and develop (what's coming next), plus three kinds of temporary ones: feature/* off develop, release/* to stabilize a version, and hotfix/* for urgent fixes straight from main.

It was designed for software that ships in versions: a mobile app that goes through store review, a library with a 2.x and a 3.x line, an on-premise product that customers install. In that world, having a place to stabilize release 4.2 while 4.3 is being built is genuinely useful.

For a web service that deploys whenever it's ready, it's mostly overhead. You end up maintaining develop and main as two almost identical branches, merging hotfixes in two directions, and feature branches tend to live for weeks because "they'll go in the next release anyway." If your team uses Git Flow and deploys a web app several times a week, it's worth asking what the develop branch is actually buying you.

GitHub Flow

GitHub Flow is much simpler. There's one long-lived branch, main, and it's always deployable. You branch off main, open a pull request, get it reviewed, merge it, and deploy. That's the whole model.

It fits most teams building web services and APIs. The key assumption is that merging to main means it's ready to go out, so it depends on decent automated tests and a deploy pipeline you trust. Without those, "main is always deployable" is a hope, not a rule.

Its weak spot is the same as everyone's: nothing in the model stops a feature branch from living for three weeks. GitHub Flow works well when branches last a day or two. It works badly when they don't.

Trunk-based development

Trunk-based development pushes the idea to its limit. Everyone integrates into main (the "trunk") at least once a day, either by committing directly or through branches that live for hours. Unfinished work is merged anyway, hidden behind feature flags, so it ships dark and is turned on when it's ready.

This is what high-performing teams in the DORA research tend to do, and it removes most merge pain by simply never letting branches drift. But it asks a lot: fast and reliable CI, strong test coverage, a feature flag system, and engineers who are comfortable splitting work into small, safe steps. Moving to trunk-based without those is how you get a broken main every afternoon.

How to pick one

The honest answer is that the right strategy depends less on taste and more on how you release and how much you trust your automation. Here's the rough decision guide I'd use:

A decision flow. First question: do you ship versioned releases, or support more than one version at a time? If yes, use Git Flow or a release-branch model. If no, second question: do you have fast, reliable CI and can you deploy on every merge? If no, use GitHub Flow and invest in CI first. If yes, third question: do you have feature flags and a habit of small changes? If no, use GitHub Flow with branches under two days. If yes, use trunk-based development.

A few things this guide doesn't show, but which matter just as much:

  • Pick one and write it down. A short CONTRIBUTING.md section with branch naming, how to merge and who can push to main removes a whole category of arguments in code review.
  • Enforce it with the platform, not with memory. Branch protection, required checks and required reviews do more than any wiki page.
  • Revisit it when your release process changes. Moving from monthly releases to continuous deployment is a good reason to drop develop. Many teams keep Git Flow for years after the reason for it is gone.

You also don't have to adopt any of these exactly. Plenty of teams run GitHub Flow plus a short-lived release/* branch when a big launch needs stabilizing. The names matter less than the rules.

Rebase vs. merge, without the religion

The other Git argument every team has is rebase vs. merge. Both put your changes together with someone else's. They differ in what history looks like afterwards.

Merge keeps history exactly as it happened and adds a merge commit to join the two lines. It's safe and never rewrites anything, but a busy repository ends up looking like a subway map.

Rebase replays your commits on top of the latest main, as if you had started from there. History stays linear and easy to read. The catch is that it rewrites your commits, so it creates new ones with new hashes.

Here's the rule that ends most of these debates:

Rebase what's only yours. Never rewrite history someone else has pulled.

In practice, that means:

  • Rebase your own feature branch onto main before opening or updating a PR. git pull --rebase (or git config pull.rebase true) saves you from the pointless "Merge branch 'main' into feature" commits.
  • Clean up locally. git rebase -i to squash "fix typo" and "wip" commits into something a reviewer can read commit by commit.
  • Don't force-push to shared branches. If someone else works on your branch, talk first, and use --force-with-lease instead of --force so you don't wipe out commits you haven't seen.
  • Choose one merge style for main and set it in the repo. Squash-merge gives one commit per PR and a very clean main. A merge commit keeps the individual commits inside the PR. Either works. Mixing them randomly doesn't.

The point of all this isn't pretty graphs. It's that six months from now, somebody will run git log or git blame on a line that's breaking production, and they'll need to understand why it changed. A readable history with good commit messages is documentation you get almost for free.

What to do on your team this week

You don't need to be the tech lead to improve this. A few things you can start on your own:

  • Keep your branches under two days. If a feature is bigger, split it: merge the migration first, then the service code behind a flag, then the UI.
  • Rebase onto main every morning while a branch is open. Small, daily conflicts are easy. One big conflict at the end is not.
  • Write the strategy down if nobody has. Even half a page, proposed in a PR, will get the conversation going.
  • Suggest branch protection on main if it isn't there: required CI and at least one review.
  • Learn git reflog. It's the undo button for almost every rebase mistake, and knowing it makes you much less afraid of rewriting your own local history.

The short version

  • A branching strategy is a team agreement about how work reaches main, not a set of Git commands.
  • The longer a branch lives, the more expensive it is to merge. Keep them short.
  • Git Flow fits versioned releases. GitHub Flow fits most web services. Trunk-based fits teams with strong CI and feature flags.
  • Pick based on how you release and how much you trust your automation, then write it down and enforce it with branch protection.
  • Rebase your own work, never rewrite shared history, and choose one merge style for main.

Next up, Part 3 looks at what happens once your branch is ready: writing pull requests that senior engineers actually want to review.

This is Part 2 of 18 in the series. The Senior Engineer Roadmap maps the whole series, with a short self-assessment and four reading orders.