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 + PRsmainis always deployable.- Create a descriptive branch from
main. - Commit, push, and open a PR early (a draft PR is fine).
- Review, plus CI tests on every push.
- Merge to
main, which deploys automatically.
Best for: web apps and SaaS products with continuous deployment, and most teams.
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 offdevelop, andrelease/*branches stabilise a version.hotfix/*branches come offmainfor 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
git tag -a v1.4.0 -m "Release 1.4.0: price filters"
git push origin v1.4.0 # tags aren't pushed by defaultA 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
# .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 testMonorepos 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-leaseon your own - Never commit secrets; use
.gitignoreand 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.
1.In GitHub Flow, what's always true about main?
2.What does a MINOR version bump (1.3.0 → 1.4.0) signal?