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
.gitat the top of the repository. You never edit it by hand. Because its name starts with a dot, plainlsdoesn’t show it;ls -adoes (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
.gitfolder. - 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?
Question 2 · Multiple choice
Which statement about Git and GitHub is correct?
- Git and GitHub are two names for the same program.
- Git is a program on your computer; GitHub is a website that hosts Git repositories.
- GitHub is a program on your computer; Git is the website where you upload it.
- You must install GitHub before you can install Git.
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 |
Question 4 · True or false
You need a GitHub account to use Git.
Question 5 · Short answer
Name two websites other than GitHub that host Git repositories.
Question 6 · Short answer
List the four pieces of information that every commit records.
Medium
Question 7 · Multiple choice
Which of the following is not something version control does for you?
- Lets you see which lines of a file changed between two versions
- Lets you go back to an earlier version of your project
- Automatically finds and fixes bugs in your code
- Lets you keep a backup copy of the whole history on another computer or website
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.
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?
Question 10 · Multiple choice
Where does Git store the history of a repository?
- On GitHub only
- In a hidden folder named
.gitat the top of the repository - Inside each file, at the bottom
- In a file named
history.txtin your home directory
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).
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?
Question 13 · True or false
If you delete the .git folder of a repository, all your project files are deleted too.
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.
Question 15 · True or false
“Claude Code has checkpoints that can rewind its edits, so I don’t need Git.”
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.
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).
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?