26  26. What Is Version Control? (Git vs. GitHub)

Every software project, from a student website to Google Search, keeps its files under version control. This page explains what version control is, why it matters even more when an AI agent edits your code, and the difference between Git and GitHub. The next pages put it into practice.

26.1 The problem: report_final_v2_ACTUAL.docx

You have probably seen (or created) a folder like this:

report.docx
report_final.docx
report_final_v2.docx
report_final_v2_ACTUAL.docx

Which one is the latest? What changed between v2 and ACTUAL? Can you get back the paragraph you deleted last Tuesday? Who changed the numbers in section 3? Now imagine a project with 200 files that changes every day.

Version control is a system that records changes to a set of files over time, so you can see what changed, when, by whom, and why, and go back to any earlier version. You keep one copy of each file with its real name (report.docx), and the version control system remembers all the older versions for you.

26.2 Snapshots: save points for your project

With version control, you take a snapshot of your project whenever you reach a good point: “the home page works”, “fixed the typo in the menu”. In Git, a snapshot is called a commit. Think of a commit as a save point in a video game: if something goes wrong later, you can always go back to it.

Each commit records:

  • the state of all the project’s files at that moment,
  • a short message describing the change,
  • the author and the date,
  • a unique ID (a “hash” such as 4293e1d).

The list of all commits is the project’s history:

  ffd1f1f                    b90f840                     4293e1d
  "Add starter files   --->  "Describe planned    --->   "Add intro and contact
   for portfolio site"        pages in README"            email to home page"
  Oct 6, 10:15               Oct 6, 10:22                Oct 7, 14:05
                                                         (newest)

Here is the same history as Git prints it. You’ll create this exact project yourself on the next pages:

4293e1d (HEAD -> main) Add intro and contact email to home page
b90f840 Describe planned pages in README
ffd1f1f Add starter files for portfolio site

What you get from version control:

Benefit What it means for you
History See what changed, when, and why, line by line.
Undo Throw away a bad change, or bring back an old version of a file or of the whole project.
Safe experiments Try a risky idea. If it fails, go back to the last commit.
Backup Keep a copy of the whole history online (for example on GitHub). If your laptop dies, your work survives.
Collaboration Several people can work on the same project without emailing files around. This is covered later, in the part Git and GitHub: Working with Others.

26.3 Git vs. GitHub

These two names confuse almost everyone at first.

  • Git is a free, open-source version control program that runs on your computer. It was created in 2005 by Linus Torvalds (the creator of Linux) and is by far the most widely used version control system today. Git works offline and doesn’t need an account.
  • GitHub (github.com) is a website (owned by Microsoft) that stores copies of Git projects online and adds tools for sharing them and working on them together. GitLab and Bitbucket are popular alternatives that do the same job.
Git GitHub
What it is A program A website / online service
Where it runs On your computer In the cloud
Needs internet? No Yes
Needs an account? No Yes (free accounts are available)
Alternatives (rarely needed; Git dominates) GitLab, Bitbucket

An analogy: Git is like your phone’s camera, which takes the photos (the snapshots). GitHub is like an online photo album where you upload copies to keep them safe and share them. You can take photos without ever uploading them, but the album is handy for backup and sharing.

26.4 Key words: repository, commit, and the .git folder

  • A repository (or repo) is a project folder whose history Git keeps track of.
  • Git stores the entire history inside a hidden folder named .git at the top of the repository. You never edit it by hand. Because its name starts with a dot, plain ls doesn’t show it; ls -a does (see Files, Folders, and Paths).
git-tutorial-project/     <- the repository (your project folder)
├── .git/                 <- Git's database: every commit, the whole history
├── README.md             <- your files, which you edit normally
├── css/
│   └── style.css
└── src/
    └── index.html

If you delete the .git folder, your files stay, but the history is gone and the folder is no longer a repository.

Git also thinks of your project in three areas. You’ll use them on the next pages; for now, just notice that saving a snapshot is a two-step process:

 working directory   ---git add--->   staging area   ---git commit--->   repository
 (the files you see                   (changes you                      (the saved commits,
  and edit)                            picked for the                    stored in .git)
                                       next commit)

26.5 What Git is good at

Git works with any kind of file, but it shines with plain text files: code, HTML, CSS, Markdown, CSV. For text files it can show you exactly which lines changed. For binary files such as Word documents, Excel workbooks, or images, Git can store each version but can’t show you what changed inside them. That is one more reason programmers write code in text editors, not word processors (see Writing to Files). Git is also not designed for very large files such as videos.

26.6 Why Git matters even more with AI coding agents

As of Oct 6, 2026 · Official docs: How Claude Code works · Checkpointing

An AI agent such as Claude Code can change dozens of files in a minute. Sometimes the result is great; sometimes it breaks something in a way you don’t notice right away. Git is your safety net:

  • Commit before you let the agent work. Afterwards, Git shows you exactly which files and lines the agent changed, and you can undo all of it.
  • Claude Code can run Git for you. It can run any command you could run in the terminal, including git. It also sees your Git state (current branch, uncommitted changes, recent commits) and commits changes when you ask. You still need to understand Git to check what it did (see Working Effectively with Claude Code).
  • Claude Code’s checkpoints don’t replace Git. Claude Code can rewind its own file edits within a session, but its docs say checkpoints are not a replacement for version control. For example, they don’t capture files changed by shell commands that Claude runs (such as rm). Use Git for permanent history.

Older version control systems kept the history on one central server; you had to be online to save a version. Git is a distributed version control system: every copy of a repository (your laptop, GitHub, a second computer) holds the complete history. That is why you can commit on a plane, and why a copy on GitHub is a real backup rather than just a list of files.

A commit ID is a hash: a 40-character code (letters a-f and digits) that Git calculates from the commit’s contents, for example 4293e1d6b36575de7e70186a7c2900f518313af0. If anything in the commit changed, even one character, the hash would be different. Because the full hash is long, Git usually shows only the first 7 characters (4293e1d), which is enough to identify a commit within a project.

26.7 Key takeaways

  • Version control records snapshots (commits) of your project, so you can see the history and go back to any earlier version.
  • Git is the program on your computer; GitHub is a website that hosts copies of Git repositories (alternatives: GitLab, Bitbucket).
  • A repository is a project folder tracked by Git; its history lives in the hidden .git folder.
  • With AI agents editing your code, Git is your safety net: commit first, review the changes, undo if needed.

Practice Questions

Easy

Question 1 · Short answer

In one or two sentences, what is version control?

A system that records changes to a set of files over time, so you can see what changed, when, by whom, and why, and go back to any earlier version.

Question 2 · Multiple choice

Which statement about Git and GitHub is correct?

  1. Git and GitHub are two names for the same program.
  2. Git is a program on your computer; GitHub is a website that hosts Git repositories.
  3. GitHub is a program on your computer; Git is the website where you upload it.
  4. You must install GitHub before you can install Git.

b. Git is the version control program that runs on your computer. GitHub is an online service that stores copies of Git repositories and adds sharing and collaboration tools. They are not the same thing (a), the roles in (c) are reversed, and Git works fine without GitHub (d).

Question 3 · Matching

Match each term with its meaning.

Term Meaning
1. repository A. a snapshot of the project with a message, author, date and ID
2. commit B. the hidden folder where Git stores the whole history
3. .git C. a website that hosts Git repositories
4. GitHub D. a project folder whose history Git tracks
5. working directory E. the files you actually see and edit

1 → D, 2 → A, 3 → B, 4 → C, 5 → E.

Question 4 · True or false

You need a GitHub account to use Git.

False. Git is a program that runs on your own computer and works offline without any account. You only need a GitHub (or GitLab, Bitbucket) account if you want to store a copy of your repository online.

Question 5 · Short answer

Name two websites other than GitHub that host Git repositories.

GitLab and Bitbucket.

Question 6 · Short answer

List the four pieces of information that every commit records.

  1. The state (snapshot) of the project’s files at that moment.
  2. A message describing the change.
  3. The author and the date.
  4. A unique ID (hash), such as 4293e1d.

Medium

Question 7 · Multiple choice

Which of the following is not something version control does for you?

  1. Lets you see which lines of a file changed between two versions
  2. Lets you go back to an earlier version of your project
  3. Automatically finds and fixes bugs in your code
  4. Lets you keep a backup copy of the whole history on another computer or website

c. Version control records and restores versions; it does not understand or fix your code. Showing line changes (a), going back (b), and keeping a backup copy of the history elsewhere (d) are all core benefits.

Question 8 · Scenario

Your team folder contains budget.xlsx, budget_final.xlsx, budget_final_v2.xlsx and budget_final_v2_ACTUAL.xlsx. Explain how a version control system would organize this differently.

There would be just one file, budget.xlsx. Each time it reaches a good state, you make a commit with a message such as “Add Q3 forecast”. The version control system stores all the earlier versions in its history, with the date, the author and the message, so you can always see or restore an older version without keeping extra copies with confusing names.

Question 9 · Short answer

Git can store every version of a Word document, but it can’t show you what changed inside it. Why? What kind of file does Git handle best?

A Word document is a binary file, not plain text, so Git can’t compare it line by line. Git works best with plain text files (code, HTML, CSS, Markdown, CSV), where it can show exactly which lines were added, removed, or changed.

Question 10 · Multiple choice

Where does Git store the history of a repository?

  1. On GitHub only
  2. In a hidden folder named .git at the top of the repository
  3. Inside each file, at the bottom
  4. In a file named history.txt in your home directory

b. All commits are stored in the hidden .git folder. GitHub (a) is only an optional online copy; Git never adds history to your files (c); and there is no history.txt file (d).

Question 11 · Ordering

Put these steps in the order a change travels through Git’s three areas:

  • A. The change is saved as a snapshot in the repository.
  • B. You edit a file in the working directory.
  • C. You choose the change for the next commit (it goes to the staging area).

B → C → A. You edit files in the working directory, use git add to put the changes you want into the staging area, and then use git commit to save them as a snapshot in the repository. (You’ll practice this in Your First Repository.)

Question 12 · Short answer

Maria runs ls in her repository and doesn’t see a .git folder. Is something wrong? How can she check that it’s there?

Nothing is wrong. .git starts with a dot, so it is a hidden folder and plain ls doesn’t list it. ls -a shows hidden files and folders, including .git.

Question 13 · True or false

If you delete the .git folder of a repository, all your project files are deleted too.

False. Your current files stay where they are, but the history (all the commits) is lost, and the folder is no longer a Git repository. Never delete .git unless you really want to throw away the history.

Hard

Question 14 · Scenario

You asked Claude Code to “clean up the styling”. It changed 12 files and now the website looks broken. Explain how Git helps in this situation, and what you should have done before asking Claude Code to start.

Before: commit your working project, so you have a known-good snapshot.

After: because the last commit is a known-good state, Git can show you exactly which files and lines the agent changed since then, so you can review them, keep the good parts, and undo the rest, or throw away all the changes and go back to the commit. Without a commit before the agent started, there is no clean point to compare against or return to.

Question 15 · True or false

“Claude Code has checkpoints that can rewind its edits, so I don’t need Git.”

False. Checkpoints are meant for quick undo within a Claude Code session. The Claude Code docs say they are not a replacement for version control. For example, they don’t capture files changed by shell commands that Claude runs (such as deleting a file with rm). Git gives you permanent history, backups (with GitHub), and collaboration.

Question 16 · Compare

A classmate says: “I don’t need Git. My project folder is in a cloud drive (Dropbox, OneDrive, Google Drive), and it keeps old versions of my files.” Give two things Git gives you that a cloud drive’s version history does not.

Any two of:

  • Snapshots of the whole project with a message. A commit records all files together at a meaningful moment (“Add contact page”), not just automatic saves of individual files.
  • Line-by-line comparison of any two versions of your code.
  • You decide when to save a version, so each commit is a working, meaningful state rather than every half-finished edit.
  • Tools built for code: undoing a single change, viewing an old version of the whole project, and (later) collaborating with branches and pull requests.

A good answer contrasts meaningful, project-wide, described snapshots with automatic copies of individual files.

Question 17 · Long answer

Maria works alone and never plans to share her code. Give three reasons why she should still use Git (and GitHub).

  1. Undo: she can go back to a working version after a bad change, whether she made it or an AI agent did.
  2. History: she can see what changed, when, and why, which helps her find out when a bug appeared.
  3. Backup: a copy on GitHub survives a lost or broken laptop.
  4. Working from two computers: she can move her work between a laptop and a lab PC through GitHub (Cloning and Pulling).
  5. Portfolio: employers often look at GitHub profiles.

Any three of these, explained, make a good answer.

Question 18 · Short answer

Git is called a distributed version control system. What does that mean, and why does it make a copy on GitHub a real backup?

Every copy of a Git repository holds the complete history, not just the latest files. So the copy on GitHub contains every commit, and if your laptop is lost you can recover the whole project, history included. It also means you can commit while offline.

© 2025-2026 Y. Rosenthal. All rights reserved.