‹ Start From Zero Lesson 4 of 21
Contents Lesson 4 of 21

3 min read · foundations

Git — the undo button for everything you write

Course 1 lesson 1 mentions "git history" as though you already know what that is. This is where you find out, and it takes twenty minutes.

What problem it solves

You change something, it breaks, and you cannot remember what it looked like before. Every beginner solves this with index-final-FINAL-v2.js, and that solution collapses within a week.

Git records snapshots you choose, with a note saying why. You can go back to any of them, and you can see exactly what changed between two.

Four commands, in the order you use them

git init                        start recording this folder (once)
git status                      what has changed since the last snapshot
git add .                       choose everything changed for the next snapshot
git commit -m "why"             take the snapshot

Then git log lists them and git diff shows what changed. That is a working knowledge of git for this entire track.

The message is the point

git commit -m "stuff" is a snapshot you cannot find later. -m "fetch prices before rendering, so the table is never empty on load" is one you can.

The message is written for you in three months, who will not remember. This is the same reader the whole build track keeps coming back to, and it is worth writing for them from your first commit.

Commit small, and often

One idea per commit. Not "a day's work" — a change you can describe in one sentence.

This matters much more with an assistant than without one, and course 1 explains why in detail: when a generated change breaks something, small commits let you find and undo exactly the part that broke. A day of generated work in one commit is a day you either keep entirely or lose entirely.

.gitignore, briefly

Some things must never be recorded: secrets, and anything the machine can regenerate. A file called .gitignore lists them. You will meet a real one in course 1, where the line that matters holds your API key. For now just know that "git records everything in the folder" has deliberate exceptions.

Try it now

In your course folder: git init, create a file, git add ., git commit -m "first commit". Then change the file, run git diff, and read what it shows you. Those coloured + and - lines are what "reading a diff" means, and course 1 spends a whole unit on the habit.