What is version control?
Overview
Imagine writing an essay without an undo button, where every save overwrites the last one. Now imagine five people editing it at once. That’s software development without version control.
A version control system (VCS) records changes to files over time so that you can:
- see what changed, who changed it, when, and — if they wrote a good message — why;
- go back to any earlier version of a file or the whole project;
- compare any two versions;
- work in parallel on different features and combine the results;
- find when a bug was introduced, and by which change.
Three approaches
No version control
Copying files with new names, emailing zip files, “track changes” in a document. It works for one person for a short time. It breaks down as soon as you need to know which copy is current, or combine two people’s edits.
Centralised version control
Systems like Subversion (SVN) and Perforce keep the history on one central server. You check out the latest files, change them and commit back to the server. It was a big improvement, but:
- you need a network connection to commit, view history or compare versions;
- if the server goes down, nobody can work with history — and if it’s lost, the history is lost;
- branching is usually slow and heavyweight, so teams avoid it.
Distributed version control
In a distributed system like Git, every copy of the project — called a clone — contains the complete history. You commit, branch, compare and browse history entirely on your own computer, with no network. When you’re ready, you exchange commits with other copies.
A shared server such as GitHub still exists, but it’s a convenient meeting point rather than the only home of the history. Every clone is effectively a full backup.
Why Git won
Git was created by Linus Torvalds in 2005 to manage the Linux kernel — a huge project with thousands of contributors. It was designed to be:
- Fast: almost everything happens locally, so commands finish instantly.
- Distributed: offline work, and no single point of failure.
- Good at branching: creating a branch takes milliseconds, so you can use one for every task.
- Safe: every commit is identified by a cryptographic hash of its contents and its history, so history can’t be silently altered or corrupted.
Today Git is used by the overwhelming majority of developers. GitHub alone hosts hundreds of millions of repositories, and GitLab, Bitbucket and others are also built on Git. Learning Git is learning the version control system you’ll use at almost any job.
What to put under version control
Git is designed for text files that people write: source code, HTML and CSS, Markdown documentation, configuration files, scripts, SQL migrations, even books and articles.
It’s less suited to:
- Generated files — build output, compiled code,
node_modules. They can be recreated, so you tell Git to ignore them (Ignoring files). - Secrets — passwords, API keys. Anything committed is in the history forever, and shared with everyone who clones (Keeping secrets safe).
- Large binary files — videos, big datasets, design files. Git stores every version in full, so repositories grow fast. Extensions like Git LFS (Large File Storage) handle these.
Words you’ll hear all the time
| Term | Meaning |
|---|---|
| repository (repo) | a project folder plus its complete history |
| commit | a saved snapshot of the project, with a message |
| branch | an independent line of work |
| merge | combining the work of two branches |
| clone | a full copy of a repository, history included |
| remote | another copy of the repository you exchange commits with — often on GitHub |
| push / pull | send your commits to a remote / get commits from it |
Each gets its own lesson. The exercise gives you a quick preview of the first two.
The big idea: with Git, you stop worrying about breaking things. Every version you’ve committed is still there, and you can always get back to it.
Your first taste of history
Run this script in an empty folder. It creates a tiny repository, saves two versions of a file, and then asks Git three questions: what is the history, what changed between the versions, and what did the file look like before? Read each command’s output and match it to the idea it demonstrates — you’ll learn every command properly in the next chapter.
mkdir notes && cd notes
git init -b main
echo "Buy milk" > todo.txt
git add todo.txt
git commit -m "Start todo list"
echo "Call the bank" >> todo.txt
git add todo.txt
git commit -m "Add bank reminder"
# 1. Show the history (one line per version)
# 2. Show what changed in the latest version
# 3. Show the file as it was in the first versionmkdir notes && cd notes
git init -b main
echo "Buy milk" > todo.txt
git add todo.txt
git commit -m "Start todo list"
echo "Call the bank" >> todo.txt
git add todo.txt
git commit -m "Add bank reminder"
# 1. Show the history (one line per version)
git log --oneline
# 2. Show what changed in the latest version
git show --stat HEAD
git show HEAD # the full change: + Call the bank
# 3. Show the file as it was in the first version
git show HEAD~1:todo.txt # → Buy milkSummary
- Version control records every change to a set of files, with who made it, when and why.
- It lets you compare versions, go back in time, work in parallel and find when a bug appeared.
- Centralised systems keep history on one server; distributed systems like Git give every copy the full history.
- Git is fast, works offline, makes branching cheap and protects history with cryptographic hashes.
- Version control is for any text you care about — code, documentation, configuration, even writing.