Why version control exists
The folder-copy problem that made version control necessary, and the three ideas (history, branches, sharing) that a tool like Git adds on top.
Why version control exists
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- Copying folders as a backup records that files changed but not what changed, who changed it, or why.
- A version control system keeps a named, ordered history of your project, so any earlier state can be inspected or restored.
- Centralized systems keep the history on one server. Distributed systems like Git give every developer a full copy of it.
- Because every Git clone holds the whole history, you can commit, browse history and branch with no network.
- Git is the tool, and GitHub is a website that hosts Git repositories. They are separate things.
The problem with copying folders
You are building a small notes tool, a script that appends a line to a text file and prints the lines back. It works. Before you try something risky, you copy the folder:
tinynotes/
tinynotes-backup/
tinynotes-final/
tinynotes-final-v2/
tinynotes-final-v2-REALLY-final/
This is an illustration, not a transcript, but you have probably seen a folder like it. Look at what the copies can and can’t tell you.
- They don’t say what changed. To find the difference between
finalandfinal-v2you have to open files and compare by eye. - They don’t say why. Six weeks later you will not remember what
v2fixed. - The order is a guess.
final-v2sounds newer thanbackup, but the name is just text. - They waste space and effort. Each copy repeats files that never changed.
- Two people can’t use them. If a friend edits their own copy of
final, you have two diverging projects and no safe way to combine them.
The core problem is that a copy stores a state and nothing about the journey between states. Version control exists to store the journey.
What a version control system adds
A version control system (VCS) is a program that records the changes to a set of files over time. Three ideas do most of the work.
History. Every time you decide a piece of work is worth remembering, you record a snapshot with a message and an author. The snapshots form an ordered list. You can ask what the project looked like last Tuesday, who changed a line, or bring one file back from three snapshots ago.
Branches. Sometimes you want to try something without disturbing the working version. A branch is a separate line of history. You experiment on it, and if it works you fold it back in. If it doesn’t, you throw it away. The folder copy was a crude, manual branch.
Sharing. Two people can work on the same project at once, and the system helps combine their work, flagging the spots where they edited the same lines.
Centralized and distributed
Early systems such as CVS and Subversion were centralized. One server held the real history, and you checked files out from it. That has a clear weakness. Without the server you can’t see history or save your work in the system, and if the server’s disk dies, the history goes with it unless someone made a backup.
Distributed systems, which include Git and Mercurial, work differently. When you copy a repository (Git calls this a clone) you get the entire history, not just the latest files. Every clone is a full backup, and nearly every operation happens on your own machine. That is why git log is instant and works on an aeroplane.
A restaurant analogy fits. In a centralized system the kitchen keeps the only recipe book, and cooks must go ask for a page. In a distributed system every cook owns a full copy of the book and they occasionally compare notes.
Git and GitHub are different things
People say “Git” when they mean either, so fix it now.
- Git is the program. It is free and open source, it runs on your machine, and it works with no account and no internet.
- GitHub is a company’s website that hosts Git repositories and adds pull requests, issues and automation. GitLab and Bitbucket are alternatives.
This roadmap starts with Git alone, in a folder on your disk. GitHub comes much later, in the groups on collaboration and the platform.
What the video covers
Computerphile’s “Git Version Control _final_new_final.new” is about seven minutes and was published in February 2022. The title is the folder-copy problem from the top of this page, and the description says Dr Max Wilson takes a quick look at versions and branches in Git. I couldn’t read a transcript, so that is all I can vouch for: it is a talk about versions and branches, and it does not walk through the centralized versus distributed comparison above. The channel publishes in English, and I judged the language from the title and description, not by listening. Watch it for the idea of keeping versions in one place, and use this page for the rest. Simplilearn’s older video is linked as a second, more definitional take.
Where this fits
You now know what problem Git solves. Next you need Git on your machine, with your name attached to what you record: installing and configuring Git. If you want a quick tour of everyday Git before the details, the frontend roadmap has version control with Git.
Check yourself
Why is a folder named project-final-v2 a poor version history?
The name carries no record of what changed, why, or in what order, and two people editing copies cannot be combined safely.
What can you still do in a distributed system when the server is down?
Everything except sharing: each clone has the full history, so you can commit, read the log and create branches locally.
Are Git and GitHub the same thing?
No. Git is the version control program that runs on your machine. GitHub is a hosting service for Git repositories, with collaboration features on top.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.