Git/
Lesson

You know how to create branches and make commits. But when you joinWhat is join?A SQL operation that combines rows from two or more tables based on a shared column, letting you query related data in one request. a real team, you discover that knowing Git commands is only half the battle. The other half is agreeing on how to use them together. Without shared conventions, every developer does their own thing, and the repositoryWhat is repository?A project folder tracked by Git that stores your files along with the complete history of every change, inside a hidden .git directory. becomes a mess.

Think of a Git workflow like traffic laws. Every driver knows how to steer and brake, but without rules about which side of the road to drive on, intersections become chaos. A workflow is your team's traffic code for version control.

AI tools like ChatGPT routinely suggest workflows that skip code review entirely. They will tell you to commit and push straight to main because they optimize for speed, not for team safety. In a professional setting, that advice can break production for everyone.

Why your team needs a workflow

Without a shared workflow, these problems surface within days:

ProblemWhat happensReal cost
No code reviewBugs ship to production uncheckedOutages, angry users
Everyone on mainConstant merge conflictsHours lost resolving them
No branch namingNobody knows who works on whatDuplicated effort
No release process"Is this deployed?" becomes a daily questionConfusion, missed deadlines
No hotfix strategyEmergency fixes take hours instead of minutesRevenue loss during downtime

A good workflow solves all of these by establishing clear rules: where to branch from, how to name branches, when to merge, and who reviews the code before it reaches production.

02

The three main workflows

There are three dominant Git workflows used in the industry today. Each fits a different team size and release cadence.

GitHub Flow

The simplest workflow. You have one permanent branch (main) and create short-lived feature branches for every change.

# 1. Create a feature branch from main
git checkout main
git pull
git checkout -b feature/add-search

# 2. Work on your feature, commit often
git add src/search.js
git commit -m "feat: add search input component"

# 3. Push and open a pull request
git push -u origin feature/add-search
# Open PR on GitHub for code review

# 4. After approval, merge into main
# (Usually done via the GitHub UI)

# 5. Delete the feature branch
git branch -d feature/add-search

GitHub Flow works best for teams that deploy continuously. There is no separate "release" step because every merge to main is a potential deployment.

Git Flow

A more structured workflow designed for teams with scheduled releases. It uses five branch types:

main ─────────────────────────────────── (production)
  \                                    /
   develop ──────────────────────────── (integration)
     \          \            /
      feature/x  feature/y  (merged to develop)
                  \
                   release/1.2 ──────── (testing)
                                \
main ────────────────────────────── (tagged v1.2)
  \
   hotfix/critical ──────────────────── (emergency)
Branch typeCreated fromMerges intoPurpose
main,,Production-ready code only
developmainmain (via release)Integration branch for features
feature/*developdevelopIndividual features
release/*developmain + developRelease preparation and testing
hotfix/*mainmain + developEmergency production fixes

Git Flow adds complexity but gives you clear separation between development, testing, and production code.

Trunk-Based DevelopmentWhat is trunk-based development?A workflow where all developers commit frequently to a single shared branch, relying on feature flags to hide incomplete work.

The most aggressive workflow. Everyone commits to main (the "trunk") frequently, using feature flags to hide unfinished work.

# Work directly on main with small commits
git checkout main
git pull

# Add feature behind a flag
git add src/search.js
git commit -m "feat: add search (behind feature flag)"
git push

# The feature flag controls visibility
if (featureFlags.search) {
  renderSearchBar();
}

This works for teams with strong automated testing and continuous deployment pipelines. Without those safeguards, it is risky because broken code goes straight to main.

03

Choosing the right workflow

FactorGitHub FlowGit FlowTrunk-Based
Team size1-105-50+Any (with CI/CD)
Release cadenceContinuousScheduledContinuous
ComplexityLowHighLow (but needs CI/CD)
Code reviewPR-basedPR-basedPR or pair programming
Best forSaaS, web appsMobile, desktop, versionedHigh-velocity teams

Most teams start with GitHub Flow because it is simple and effective. Only switch to Git Flow if you genuinely need scheduled releases with separate testing phases.

04

Quick reference

WorkflowBranchesMerge strategyBest fit
GitHub Flowmain + feature branchesPR merge to mainSmall teams, continuous deploy
Git Flowmain, develop, feature, release, hotfixStructured merges through branchesScheduled releases, large teams
Trunk-Basedmain onlyDirect commits with feature flagsCI/CD-heavy teams