Learn to Code
All tracks
Learn to Code

Free lessons from scratch to pro — every language, databases and DevOps.

AboutContactPrivacy PolicyTerms of Use

Your progress is saved in this browser. © 2026 Learn to Code

GIT
Git & GitHub
0/10 completed
Beginner
What is version control?Your first commitsBranchesGitHub and remotes
Intermediate
Merging and conflictsUndoing changesPull requests and code reviewRebasing
Advanced
Git internals
Pro
Git workflows for teams
Tracks / Git & GitHub / Pro

Git workflows for teams

You know the commands. Now the question is how should a team use them together? A workflow is an agreement about branches, merging, releases and automation. Picking the right one can make the difference between shipping daily and dreading every release.

1. GitHub Flow (simple, very popular)

main ──●────●────────●──────●────▶   always deployable
        \       /     \    /
         ●──●──●       ●──●          short-lived feature branches + PRs
  1. main is always deployable.
  2. Create a descriptive branch from main.
  3. Commit, push, and open a PR early (a draft PR is fine).
  4. Review, plus CI tests on every push.
  5. Merge to main, which deploys automatically.

Best for: web apps and SaaS products with continuous deployment, and most teams.

Git terminal (simulator) · editable

2. Trunk-based development (what high-performing teams do)

Everyone integrates into main (the "trunk") at least daily, using very small branches that live for hours, not weeks, or by committing directly with strong CI.

  • Unfinished features hide behind feature flags: if (flags.newCheckout) { … }
  • Requires excellent automated tests and fast CI
  • Almost no merge pain, because branches never drift far

Industry research (the DORA reports) consistently links trunk-based development with higher delivery performance.

3. Git Flow (structured releases)

main     ──●───────────────●──────────●──▶   production releases (tagged)
            \             / \        /
release      \     ●────●   \      /
              \   /          \    /
develop  ──●───●──●────●──────●──●────▶   integration branch
            \    /      \    /
feature      ●──●        ●──●
hotfix                              ●──    (from main, merged to main + develop)
  • main: only released code. develop: the next release.
  • feature/* branches come off develop, and release/* branches stabilise a version.
  • hotfix/* branches come off main for urgent fixes.

Best for: software with versioned, scheduled releases (mobile apps, desktop software, libraries) that supports several versions at once. It's too heavy for most web apps.

Comparing workflows

GitHub Flow Trunk-based Git Flow
Long-lived branches main main main + develop
Branch lifetime Days Hours Days–weeks
Release style Continuous Continuous Scheduled versions
Complexity Low Low (but needs strong CI) High

Releases and tags

Mark releases with semantic version tags: MAJOR.MINOR.PATCH.

  • MAJOR (2.0.0): breaking changes
  • MINOR (1.4.0): new features, backwards compatible
  • PATCH (1.4.2): bug fixes
bash
git tag -a v1.4.0 -m "Release 1.4.0: price filters"
git push origin v1.4.0          # tags aren't pushed by default

A pushed tag can trigger CI to build and publish the release. You saw this in the Docker track's CI/CD lesson.

Automating quality

A professional repository usually has:

  • Branch protection on main (required PRs, reviews and passing checks)
  • CI (GitHub Actions) that runs lint, tests and a build on every PR
  • Pre-commit hooks (Husky, lint-staged, pre-commit) for fast local checks
  • Conventional Commits + automatic changelogs and version bumps (semantic-release, Changesets)
  • CODEOWNERS for automatic reviewer assignment
  • Dependabot or Renovate for dependency update PRs
yaml
# .github/workflows/ci.yml
name: CI
on: [pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 22, cache: npm }
      - run: npm ci
      - run: npm run lint
      - run: npm test

Monorepos vs polyrepos

  • Monorepo: many projects in one repository (Google, Meta, and many startups). Atomic cross-project changes and shared tooling. Needs tools like Nx, Turborepo or Bazel.
  • Polyrepo: one repository per service. Simpler permissions and independent releases, but changes spanning several services are harder.

Team etiquette checklist

  • Pull and rebase often; keep branches short-lived
  • Small PRs with clear descriptions; review teammates' PRs promptly
  • Never force-push shared branches; use --force-with-lease on your own
  • Never commit secrets; use .gitignore and secret scanning
  • Write meaningful commit messages
  • Delete merged branches
  • Tag releases with semantic versions

🎓 Git track complete!

You can now use Git like a professional, from your first commit to team workflows, internals and recovery. Pair it with the Docker track's CI/CD lessons, or move on to CI/CD to automate everything.

Practice

Simulate GitHub Flow in the terminal: from main, create and merge (with --no-ff) three feature branches, one at a time. Tag the result v1.0, then make a hotfix branch, merge it, and tag v1.0.1. Check that the graph tells a clear story.

Git terminal (simulator) · editable
✎ Check your understanding

1.In GitHub Flow, what's always true about main?

2.What does a MINOR version bump (1.3.0 → 1.4.0) signal?

← Git internals