Computing Foundations › Git and GitHub › Day 35

Day 35: Git Workflows for Real Projects

Day 35 of 365 — Git Workflows for Real Projects

After this lesson you will be able to choose and run a real team git workflow — branching strategy, atomic commits with Conventional Commit messages, and semantic-versioned release tags — so a repository stays legible, releasable, and reproducible.

Course
Computing Foundations
Category
Git and GitHub
Reading time
≈ 40 min
Practical time
≈ 30 min
Lesson duration
1h 10m
Last verified
2026-07-12

Hands-on lab for this lesson

Lab files on GitHub: https://github.com/ai-roadmap-365/ai-roadmap-365.github.io/tree/main/labs/sections/computing-foundations/day-035-git-workflows-for-real-projects

  1. Get the hands-on files. Clone the labs repository once (you can reuse this clone for every lesson). This works on macOS, Linux, and Windows (PowerShell or WSL):
    git clone https://github.com/ai-roadmap-365/ai-roadmap-365.github.io.git
    cd ai-roadmap-365.github.io
  2. Open this lesson's lab. Move into the directory for this specific day. Every lab lives at the same predictable path — section / subsection / week / day:
    cd labs/sections/computing-foundations/day-035-git-workflows-for-real-projects
  3. Read the lab guide. Open `README.md` in that directory. It lists the exact commands, what each does, the expected output, and how to check your work — read it before running anything.
  4. Run it and check your work. Follow the README's "How to run" section: run the example first to see the finished result, then complete the numbered exercises in `starter/`, then run the tests. The tests pass (exit 0) only when your work is correct.
    bash tests/run_tests.sh   # or the test command named in the lab README

You can also open the lab as a local page (works offline, shows the file tree and expected output).

Learning objectives

By the end of this lesson you will be able to:

Prerequisites

Why this matters


The idea in plain language


Historical background

Diagram: how branching workflows evolved with delivery practice


What it is — and what it is not

A workflow is:

It is not:


Why it was created and what problems it solves


How it works

Branching strategies

Diagram comparing the branch shapes of trunk-based development, GitHub Flow, and Git Flow

WorkflowStructureMerges to mainBest forCost
Trunk-basedOne main; branches live hoursMany times a dayStrong test automation, continuous deploymentLittle review buffer
GitHub FlowShort branch per change, plus a PRPer reviewed changeMost web apps and servicesVery low; needs a review culture
Git Flowmain + develop, plus feature/release/hotfixOnly at releaseVersioned, installed softwareHeavy; many branches
Release branchesA release/x.y per versionFixes cherry-picked inSupporting several live versionsMaintenance per version

Commit hygiene

Diagram: an atomic commit compared with a mixed one

Conventional commits and semantic versioning

Diagram: what each part of a semantic version number means

Commit typeMeaningVersion bumpExample
fix:Backward-compatible bug fixPATCH1.4.2 → 1.4.3
feat:Backward-compatible featureMINOR1.4.2 → 1.5.0
feat!: / BREAKING CHANGE:Incompatible changeMAJOR1.4.2 → 2.0.0
docs: / test: / chore:Not user-facingnone1.4.2

Flow diagram: a sequence of commits leading to an annotated tag v1.0.0 and a labeled release, with the MAJOR.MINOR.PATCH parts of the version explained

Repository hygiene

Diagram: how Git LFS keeps large files out of the repository history

Hooks

Diagram: why git hooks are not shared by cloning


An everyday analogy

A publishing house.

PublishingGit workflow
The master bindermain
A photocopied chapter on your deskA feature branch
The copy deskReview and checks
Filing the edited pages backThe merge
”Third edition” on the spineAn annotated tag
The edition numbering ruleSemantic versioning
Scratch paper never filed.gitignore
The flat-file drawer for postersGit LFS

Examples in practice

Diagram: how git bisect binary-searches history for a bad commit

Diagram: a short-lived branch compared with a long-lived one


Implications: security, privacy, performance, scalability, and cost


Alternatives: free, open source, and commercial

Diagram: the steps of tagging and publishing a release

ToolTypeWhat it does
pre-commitFree, open sourceManages and installs hooks consistently across a team
commitlintFree, open sourceEnforces Conventional Commits
semantic-releaseFree, open sourceReads the log, decides the version, tags and publishes
git bisectFree, built inBinary search through history for a regression
Git LFSFree, open sourceLarge files outside the main history
DVCFree, open sourceDatasets and models versioned alongside code

TermWhat it actually is
WorkflowA team’s agreement about branches, review and release
Atomic commitExactly one logical change
TagA fixed name pinned to one commit
Annotated tagA tag object with tagger, date and message
Semantic versioningMAJOR.MINOR.PATCH, with defined meanings
HookA script Git runs at a lifecycle point
MonorepoMany projects in one repository

When to use it — and when not to

Diagram: short-lived branches compared with long-lived ones


The AI connection

Diagram: how semantic versioning applies to a trained model


Knowledge check

quiz:
  question: "A team deploys to production several times a day and adopts Git Flow, maintaining `main`, `develop`, and release branches. Why is this likely to cost more than it delivers?"
  options:
    - "Git Flow is built around scheduled versioned releases, so its release machinery adds ceremony a continuously deploying team never uses"
    - "Git Flow does not support hotfix branches, which continuous deployment requires"
    - "Maintaining two long-lived branches makes automated testing impossible"
    - "Git Flow requires rewriting history on every merge, which is unsafe for shared branches"
  answer_index: 0
  explanation: "Git Flow's develop and release branches exist to stabilise a version before it ships on a schedule. A team that ships continuously has no such window, so those branches carry maintenance cost while providing a buffer nobody uses — which its own author has acknowledged."

Hands-on exercise

Practise the whole release path on a local repository. Worked through fully in the Day 35 lab directory.

What you are doingCommand
Make an atomic commitgit commit -m "fix: handle empty response body"
Tag a release properlygit tag -a v1.0.0 -m "First release"
See tagsgit tag and git show v1.0.0
Find a bug by bisectinggit bisect start, git bisect bad, git bisect good <tag>
Mark each stepgit bisect good or git bisect bad, then git bisect reset
Add a pre-commit hookwrite .git/hooks/pre-commit, then chmod +x
Prove it blocks a committry to commit something the hook rejects

Expected output

Bisecting: 4 revisions left to test after this (roughly 2 steps)
9a8b7c6 is the first bad commit
tag v1.0.0
Tagger: Your Name
    First release
pre-commit: found a possible credential — commit rejected

Validate your work

Troubleshooting

Common mistakes


Practice assignment


Extension challenge


Quiz

Q1. What best describes GitHub Flow?

  1. Everyone commits directly to main many times a day with no branches
  2. Maintain long-lived develop and release branches and merge to main only at release time
  3. Short-lived branch, pull request, then merge to a deployable main
  4. Keep every feature on its own permanent branch that is never merged
Show answer

Answer: C. Short-lived branch, pull request, then merge to a deployable main

GitHub Flow is a lightweight, trunk-based-style model: branch off main, get the change reviewed as a pull request, and merge back while keeping main always deployable.

Q2. Which situation is Git Flow, with its long-lived develop and release branches, best suited to?

  1. A tiny solo experiment you will delete next week
  2. A service that deploys to production dozens of times a day
  3. A repository that stores only images and no code
  4. Versioned software shipping releases that must be supported
Show answer

Answer: D. Versioned software shipping releases that must be supported

Git Flow's extra branches pay off when you ship scheduled, versioned releases that need a stabilization period and ongoing support; for continuously deployed services the ceremony is usually more cost than benefit.

Q3. What is an atomic commit, and why does it matter?

  1. A commit with exactly one logical change
  2. A commit that is encrypted so it cannot be read
  3. The very first commit in a repository
  4. A commit that touches every file in the project at once
Show answer

Answer: A. A commit with exactly one logical change

An atomic commit does one logical thing, which makes it possible to revert just that change, review it in isolation, and use git bisect to find which commit introduced a bug.

Q4. Under semantic versioning, a project at v1.4.2 adds a new backward-compatible feature. What is the next version?

  1. v1.4.3
  2. v1.5.0
  3. v2.0.0
  4. v1.4.2-feature
Show answer

Answer: B. v1.5.0

A backward-compatible new feature increments the MINOR number and resets PATCH to zero, giving v1.5.0. PATCH is for bug fixes; MAJOR is for breaking changes.

Q5. What is the difference between a lightweight tag and an annotated tag?

  1. A lightweight tag can move, while an annotated tag is fixed
  2. A lightweight tag works only on Linux, an annotated tag only on macOS
  3. A lightweight tag is just a name; an annotated tag stores more
  4. They are two names for the same thing
Show answer

Answer: C. A lightweight tag is just a name; an annotated tag stores more

Both point at one commit, but an annotated tag (git tag -a) is a full object recording who created it, when, and why — which is what releases should use.

Q6. When is it dangerous to rebase or squash?

  1. Any time you use them at all
  2. When tidying your own local commits before they are reviewed
  3. Only on branches with fewer than three commits
  4. When rewriting history others have already pulled
Show answer

Answer: D. When rewriting history others have already pulled

Rebase and squash rewrite history into new commits. Doing that to your own unpushed work is safe; doing it to shared history breaks everyone else's clone, so the rule is never rewrite history others already have.

Q7. What does the --no-ff flag do when you run git merge?

  1. It forces a merge commit even when a fast-forward was possible
  2. It deletes the branch being merged
  3. It skips running any tests during the merge
  4. It merges without asking for a commit message ever
Show answer

Answer: A. It forces a merge commit even when a fast-forward was possible

--no-ff ("no fast-forward") makes git create a merge commit instead of sliding main forward, so the history permanently shows the feature branch merging back — the shape of a merged pull request.

Q8. A teammate wants to commit a 3 GB dataset and a .env file containing an API key. What is the right handling?

  1. Commit both normally; git handles any file the same way
  2. Keep the dataset in Git LFS and add .env to .gitignore
  3. Commit the .env file but delete it in the next commit to remove it from history
  4. Compress both into one zip and commit that instead
Show answer

Answer: B. Keep the dataset in Git LFS and add .env to .gitignore

Large binaries belong in Git LFS or outside the repo to avoid bloating history, and secrets must be excluded via .gitignore — committing a secret leaves it in history forever, even after a later deletion.

Glossary

workflow
A team's shared set of rules for how changes flow from an idea into the main line of a project — which branches exist, how changes are reviewed, and how releases are marked.
trunk-based development
A branching strategy where everyone commits to a single main branch (the trunk) many times a day, with any branches living only hours, relying on strong automated tests.
GitHub Flow
A lightweight workflow: create a short-lived branch, open a pull request for review, then merge back into a main branch that is always kept deployable.
Git Flow
A heavier branching model with long-lived main and develop branches plus temporary feature, release, and hotfix branches, suited to scheduled, versioned releases.
tag
A fixed name pinned to one specific commit that never moves, used to mark releases; contrast with a branch, which advances with each new commit.
annotated tag
A tag created with git tag -a that stores the tagger, date, and a message as a full git object — the kind used for releases.
semantic versioning
A convention that gives version numbers meaning as MAJOR.MINOR.PATCH: MAJOR for breaking changes, MINOR for backward-compatible features, PATCH for backward-compatible bug fixes.
Conventional Commits
A specification for structured commit messages of the form type(scope): description, using a small vocabulary such as feat, fix, docs, and refactor, so humans and tools can read the history.
atomic commit
A commit that contains exactly one logical change, making it possible to review, revert, or bisect that change in isolation.
Git LFS
Git Large File Storage, an extension that keeps large binaries (datasets, models, media) out of the repository's normal storage by committing a small pointer and storing the real bytes separately.
monorepo
A single repository that holds many projects together, making cross-project changes atomic and shared tooling simpler; contrast with a polyrepo, which gives each project its own repository.
pre-commit hook
A script git runs automatically before a commit is recorded, able to reject the commit — commonly used to run formatters, linters, or secret scanners.

Sources and further reading


Kept in this browser, no account needed. Your progress page turns the whole record into one link you can bookmark or open on another device.