Computing Foundations › Git and GitHub › Day 29

Day 29: Why Version Control Exists

Day 29 of 365 — Why Version Control Exists

After this lesson you will be able to explain what problem version control solves, name its core ideas — history, commits, diffs, reverting, branching, and merging — and say why the distributed design Git uses won, so you understand what every repository you touch is really doing.

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-029-why-version-control-exists

  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-029-why-version-control-exists
  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

Diagram: the parts of a single commit


Historical background

Diagram: the progression of version control systems


What it is — and what it is not

It is:

It is not:


Why it was created and what problems it solves

Diagram: dated folder copies compared with version control


How it works

The repository and the working directory

The history is a graph

Diagram: how a branch isolates work and a merge rejoins it

Diagram: a project history as a timeline of commits with a branch that splits off and merges back

Two operations that make history useful

Diagram: how reverting a change is recorded as a new commit

Centralised and distributed

Diagram: a centralized model with one server holding history beside a distributed model where every clone holds the full history


An everyday analogy

Diagram: what a diff reveals compared with what only a commit message can

A manuscript with every draft kept.

The manuscriptVersion control
Each dated draft, filedA commit
A note on why you changed itThe commit message
Comparing two drafts side by sideA diff
Drafting an alternative ending separatelyA branch
Folding that ending into the main textA merge
The draft you are working fromHEAD
Every author keeping the whole archiveDistributed

Examples in practice

Diagram: working without version control compared with working with it


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

Diagram: how text and binary files behave differently in version control


Alternatives: free, open source, and commercial

ToolTypeWhere it fits
GitFree, open sourceThe default, everywhere, for almost everything
MercurialFree, open sourceSimilar model, gentler interface, much smaller ecosystem
SubversionFree, open sourceCentralised; still found in long-lived enterprise projects
Git LFSFree, open sourceLarge binaries stored outside the repository
DVCFree, open sourceDatasets and model artifacts, versioned alongside code
Cloud drivesCommercialSyncing, not versioning — they resolve conflicts by guessing

TermWhat it actually is
RepositoryThe database holding the full history
Working directoryThe checked-out files you edit
CommitOne snapshot, with author, message and parent
DiffThe lines that differ between two states
BranchA separate line of development
MergeJoining two lines back together
HEADA pointer to the commit you are on

When to use it — and when not to

Diagram: unhelpful commit messages compared with useful ones


The AI connection

Diagram: what must be recorded for an experiment to be reproducible


Knowledge check

quiz:
  question: "A developer removes an accidentally committed API key in a new commit and pushes. Why is the key still considered compromised?"
  options:
    - "Every previous commit remains in the history, so the key is still readable in the repository"
    - "The new commit only removes the file from the working directory, not from disk"
    - "Git stores credentials separately from file contents and does not remove them"
    - "The removal commit cannot be pushed until the original commit is amended"
  answer_index: 0
  explanation: "Version control keeps every snapshot. The later commit changes what the current checkout contains and does nothing to the earlier commits, where the key is still present and readable by anyone with the repository — which is why the response to exposure is revocation, not deletion."

Hands-on exercise

Build a small history, then read it. Worked through fully in the Day 29 lab directory.

What you are doingCommand
Start a repositorygit init
Record a first snapshotgit add . && git commit -m "First version"
Make a change and record itedit, then git add and git commit
Read the historygit log --oneline
See what changed between two commitsgit diff HEAD~1 HEAD
Visit an earlier snapshotgit checkout HEAD~1 then git switch -
See the graphgit log --oneline --graph --all

Expected output

712412c Add error handling
9c1f0a3 First version
diff --git a/main.py b/main.py
+    if not response.ok:
+        raise SystemExit("request failed")

Validate your work

Troubleshooting

Common mistakes


Practice assignment


Extension challenge


Quiz

Q1. Which pair of roles best captures what a version control system does?

  1. A time machine for files, and safe collaboration
  2. A spell-checker and a file compressor
  3. A password manager and a cloud backup scheduler in one
  4. A text editor and a code compiler
Show answer

Answer: A. A time machine for files, and safe collaboration

Version control fuses two tools: a time machine that lets you snapshot and return to any earlier state, and a collaboration system that lets many people change the same files without losing work.

Q2. What is a commit?

  1. A permanent lock that prevents a file from ever being edited again
  2. A saved snapshot with author, timestamp, message, and parent
  3. A promise to finish a feature by a deadline
  4. A copy of a file uploaded to a cloud drive
Show answer

Answer: B. A saved snapshot with author, timestamp, message, and parent

A commit records the state of the tracked files plus metadata — who made it, when, a descriptive message, and a pointer to the previous (parent) commit — and a chain of commits is the project history.

Q3. Which statement about version control is accurate?

  1. It is simply an automatic backup that snapshots files on a schedule
  2. It keeps only the most recent version of each file to save space
  3. It records intentional, labeled changes and why they were made, and lets you branch and merge
  4. It is the same as a shared cloud folder that syncs your latest file everywhere
Show answer

Answer: C. It records intentional, labeled changes and why they were made, and lets you branch and merge

Unlike a scheduled backup or a sync service, version control captures deliberate, labeled changes and their reasons, keeps the full history, and supports branching and merging.

Q4. What does a diff show?

  1. The total number of files in a repository
  2. A list of every person who has ever cloned the repository
  3. The amount of disk space the history occupies
  4. The precise lines that were added and removed between two commits
Show answer

Answer: D. The precise lines that were added and removed between two commits

A diff compares two commits and reports exactly which lines changed — additions and deletions — which is how you answer "what changed?" without reading whole files.

Q5. Why did the Linux kernel project prompt the creation of Git in 2005?

  1. BitKeeper's free license was withdrawn, so a replacement was needed
  2. Its developers wanted a system with no history at all
  3. Subversion had become too fast for their needs
  4. They wanted to stop using version control entirely
Show answer

Answer: A. BitKeeper's free license was withdrawn, so a replacement was needed

The kernel had relied on BitKeeper under a free license; when that license was withdrawn in 2005, Linus Torvalds wrote Git to provide a fast, distributed, integrity-checked replacement.

Q6. In a distributed version control system such as Git, where does the project history live?

  1. Only on a single central server
  2. On every developer's clone — each holds the full history
  3. Only in the cloud, never on your machine
  4. Nowhere; distributed systems keep no history
Show answer

Answer: B. On every developer's clone — each holds the full history

Every clone in a distributed system contains the entire history, which is why committing, viewing the log, diffing, and branching are all local and instant, and why the project survives any single machine failing.

Q7. Which everyday operation is fast in a distributed system specifically because it needs no network?

  1. Downloading the entire history for the first time
  2. Inviting a new collaborator by email
  3. Viewing the commit log
  4. Buying more server storage
Show answer

Answer: C. Viewing the commit log

Because your clone already holds the full history, viewing the log — like committing, diffing, and switching branches — runs locally at disk speed with no server round-trip.

Q8. Why do practitioners put datasets, notebooks, and configurations under version control, not just source code?

  1. Because hosting platforms require every file to be a dataset
  2. Because version control automatically improves the accuracy of any dataset
  3. Because it converts binary files into text
  4. So a past result can be reproduced from the exact files used
Show answer

Answer: D. So a past result can be reproduced from the exact files used

Reproducibility depends on recovering the exact code, data reference, and configuration behind a result; committing all of them means you can check out the commit that produced a past outcome and get it back.

Glossary

version control
A system that records the full history of a set of files over time so you can recall any earlier version, see what changed, and let many people change the files without losing work.
repository
The store of a project's complete history — in Git, a hidden database (often a `.git` folder) that lives alongside the files and holds every commit.
commit
One saved snapshot of a project, stamped with its author, a timestamp, a descriptive message, a unique identifier, and a pointer to its parent commit.
snapshot
The captured state of the tracked files at the moment of a commit; a project's history is a sequence of these snapshots.
history
The ordered chain of commits that records how a project reached its current state, with each commit linked to the one before it.
diff
The precise list of lines added and removed between two commits, used to answer "what changed?" without reading whole files.
revert
Bringing back the content of an earlier commit — recorded as a new step in the history rather than by erasing the commits in between.
branch
A separate line of commits that splits off from the main line so you can experiment or build a feature in isolation without disturbing others.
merge
Folding the changes from two branches back together into one; where both changed the same lines, the system flags a conflict for a human to resolve.
centralized VCS
A version control design in which one server holds the authoritative history and developers keep only working copies, so most operations require the network (for example, Subversion).
distributed VCS
A version control design in which every developer clones the entire repository, history and all, so committing, diffing, and branching are local and instant (for example, Git and Mercurial).
clone
A full local copy of a repository, including its complete history, made when you obtain a project from another copy.
merge conflict
The situation where two branches changed the same lines and the system cannot combine them automatically, so it asks a person to decide the correct result.

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.