Chapter 1.1

What is Version Control?

Version control is a systematic way to record changes to a file or set of files over time, so that you can recall specific versions later.

The "Why Do I Need This?" Metaphor

~/Projects/website
index.html
index_v2.html
index_final.html
index_final_FOR_REAL.html
index_USE_THIS_ONE.html
index_final_v2_edit.html
index_copy(2).html

Total chaos. Which file is the actual latest? What changed? Good luck.

What's actually on disk?

When you use version control, you don't litter your folder with duplicates. You edit one file.

All the magic (the history, the snapshots, the time-travel ability) is stored invisibly inside a hidden folder called .git/.

website/
.git/The Time Machine
index.html
styles.css

Common Gotcha: Isn't this just a backup tool like Dropbox?

Dropbox saves every time you hit CMD+S, which means it saves halfway-broken code.

Git waits for you to explicitly say, "Take a snapshot NOW, and here is a message explaining what I achieved." Git connects intent to your code changes.

Try It: Initializing your first time machine

You can turn any folder into a Git repository. It just creates that magical hidden .git folder.

Terminal
$mkdir my-project
$cd my-project
$git init
Initialized empty Git repository in /Users/dev/my-project/.git/