Part 1
Chapter 1: The Blank Screen...--–- The cursor blinks on a blank terminal. It is 11:47 PM. Sarah, a talented but exhausted developer, has just spent the last four hours building a new authentication feature. The code works. The tests pass. She types rm -rf node_modules to clear some space before pushing to the server. Her finger slips. She adds a space. rm -rf / node_modules. The command begins to execute. By the time her brain catches up to her fingers—by the time she smashes Ctrl+C—it is too late. Her entire project is gone. Not just the new authentication feature. Everything. All of it. The cursor blinks on a blank screen.This is not a horror story.
This is a Tuesday. Version control exists because stories like Sarah’s happen to real people every single day. Not always from a mistyped deletion command—sometimes from a corrupted hard drive, a colleague who saved over the wrong file, an automatic update that broke everything, or simply that moment of realization: "I changed something three hours ago, and I cannot remember what, but the tests stopped passing and I cannot go back." If you have never experienced this sinking feeling, you will. The only question is whether you will have version control in place when you do.The Fundamental Problem That Most Developers IgnoreBefore we write a single Git command—and we will write many in Chapter 2 onward—we need to understand the problem that version control solves.
Not the technical problem. The human problem. The problem is this: software development is an activity that produces an irreversible sequence of changes. Every time you save a file, you destroy the previous version. Every time you delete a line, you cannot undelete it unless you remember exactly what it said. Every time you refactor a function, the old function disappears into the ether.You might think, "But my text editor has undo!" Yes. And undo works exactly until you close the editor, or until you make too many changes and the undo buffer fills, or until you do something that the editor does not track, like renaming a file. Undo is a temporary bandage, not a systemic solution.