The Folder Full of final_v2_FINAL
Everyone invents the same system before they meet Git. You are about to change something that currently works, you get nervous, and you copy the whole folder first. A week later the desktop holds site, site-backup, site-backup-2, site-FINAL, and — because the final version needed one small fix — site-FINAL-v2.
It is not a stupid system. It comes from a completely correct instinct: I want to be able to go back. The problem is that it only preserves one thing about the past, and throws away everything else you will need.
What the copy-the-folder method actually keeps
Open site-backup-2 and you can see what the project looked like at some point. That is genuinely useful, and it is where the usefulness stops.
You cannot tell when that copy was made, beyond whatever the file dates say. You cannot tell why it was made — what you were about to try, or what had just gone wrong. And if anyone else has touched the project, you cannot tell who made which copy. Six weeks later, standing in front of five folders, the only honest answer to "which one is the live version" is a guess.
The four questions
Every serious question you will ever ask about a project's past is one of four: what changed, when it changed, why it changed, and who changed it. Hold on to that list — it comes back at the end of Chapter 3, when you can answer all four in about ten seconds.
A concrete version, which becomes this book's running example two topics from now. You are building a website for your neighbourhood birdwatching club. Right now it exists as three folders on the desktop, two of them with the wrong meeting time in the header, and the club meets on Thursday.
Undo has a ceiling
The other tool everyone reaches for is the editor's undo, and it is excellent until it is not. Close the file and the undo history usually goes with it. Restart the machine and it certainly does. Undo also works in the wrong unit: it steps back one keystroke or one edit at a time, but the thing you want to undo is usually "the idea I had on Tuesday", which was forty edits across three files.
So you fall back on the folder copy, which is only as recent as the last time you remembered to make one — usually just before something scary, which is exactly when you were least likely to remember.
Two people, one file
Now add a second person. You email them the project, they fix the contact page and email it back, and in the meantime you have rewritten the home page. There are now two versions, each containing work the other does not have, and no mechanical way to combine them. Someone opens the other person's copy, copies their own changes across by hand, and hopes nothing was missed.
Notice what kind of problem that is. Nothing has broken technically; the files are all fine. The problem is that two histories exist and there is no rule for joining them. That is the problem branches and merging solve in Chapter 6, and it does not have a folder-shaped answer.
What a real solution would have to do
Before meeting the tool, it is worth writing the requirements yourself. A system that fixed all of this would have to record every version automatically rather than when you remember; attach a reason to each one in your own words; let you read any past state without disturbing the present one; and let two people change the same project without either of them losing work.
That list is not a description of Git that you are supposed to take on faith. It is the specification Git was built against, and every command in the next ten chapters is an answer to one line of it. When something later feels arbitrary, this page is usually the reason it exists.
- "Dropbox or Google Drive already does this." Cloud sync keeps the newest file and a shallow list of recent versions. It cannot tell you why a line changed, cannot group ten files into one meaningful change, and merges nothing — when two people edit at once you get a second file with "conflicted copy" in the name.
- "This is only a problem for big teams." The person most helped by version control is you, working alone, six weeks later. Teams multiply the pain; they do not create it.
- "I'll just be disciplined about naming the folders." Every developer has believed this. Naming discipline degrades exactly when the work gets interesting and the deadline gets close, which is precisely when you need it most.
- "My editor's undo is enough." It disappears when the editor closes, and it steps in keystrokes rather than in ideas. Undoing "everything I tried on Tuesday" is not something undo can express.
- Every command in this book answers a specific failure on this page.
git loganswers when. The commit message answers why.git revertanswers undo has a ceiling. Branches answer two people, one file. - Knowing the problem first is what stops Git from becoming a list of memorized commands that evaporate in a month. Commands attached to a reason survive; commands attached to nothing do not.
Knowledge Check
Your project folder holds five dated copies. Which of the four questions about the past can they actually answer?
- What the project looked like at those five moments
- Why each of those five copies was made
- Who made each copy and what they were working on
- Which lines changed between two of the copies
Why is cloud sync (Dropbox, Google Drive) not a substitute for version control?
- It keeps the newest file but records no reason for a change and cannot merge two people's edits
- It only keeps files smaller than a few megabytes, so a real project will not fit
- It stores only one version of a file, so nothing at all can be recovered
- It requires a network connection, so no work can be saved while offline
You want to undo everything you tried on Tuesday: about forty edits across three files. Why is the editor's undo a poor tool for this?
- It steps in keystrokes rather than in ideas, and it is usually gone once the file was closed
- It can only undo changes made to a single file, never changes across a whole folder
- It reverses changes in the wrong order, applying the oldest edit before the newest one
- It permanently deletes the changes it reverses, so nothing can be brought back afterwards
Two people email a project back and forth, each having changed a different page. What kind of problem is this?
- Two separate histories now exist, and there is no mechanical rule for combining them
- A storage problem, because two full copies of the project now exist on two machines
- A file corruption problem, because email attachments alter the contents of files
- A permissions problem, because neither person is allowed to edit the other's copy
You got correct