📸 Commits: save points for your project

By the end of this page you will know exactly what a save point captures, and why one tiny detail on it makes everything else possible.

1A save point is a photo of everything

In lesson 1 you met the problem: files change, and a folder full of final_v2_REAL copies is not a system. Git's answer is the save point.

Here is the single most important thing to know about it. When git takes a save point, it does not save just the file you were editing. It photographs every file in the project at that exact moment. Your code, your notes, your to-do list, all of it, frozen together. One picture of the whole project as it stood at 3:42 pm on a Tuesday.

🎮 A save point is like a save slot in a video game. The game does not save only the room you are standing in. It saves the whole world: your inventory, the map, your health, everything. Load that slot a year later and the entire world comes back exactly as it was. Git save points work the same way: the whole project, never just one file.

And once a photo is taken, it is glued into the album. Deleting a file tomorrow does not harm the photo you took today. This is why saved work in git is almost impossible to lose.

2The sticky note stapled to the photo

A photo alone is not enough. Imagine flipping through 500 nearly identical photos of the same folder. Which one had the working login page? No idea.

So git staples a sticky note to every photo. The note holds exactly three things:

  1. Your message: what changed and why, in your own words.
  2. Who took the photo, and when.
  3. Which photo came just before this one.

Items 1 and 2 are handy. Item 3 is the magic one. Because every photo points back to the photo before it, the photos link up into a chain, and that chain is your project's entire history. Lesson 3 is built on this one idea, so tuck it away somewhere safe.

src/ docs/ TODO.md ... the photo before src/ docs/ TODO.md README.md ... every file, frozen The sticky note 1. what changed + why 2. who took it + when 3. the photo just before

That dashed arrow, the "photo just before" line, is the thread that will turn loose photos into a proper album.

3"Wait, isn't storing the whole project every time wasteful?"

Fair question. Five hundred photos of the whole project sounds like five hundred full copies of everything. It is not: under the hood git is clever and quietly stores only what is actually new, so your disk is fine. You do not need to think about how. Keep the simple picture in your head: every save point is a photo of everything.

4The official name, and the receipt number

You now understand the idea completely: a photo of every file, plus a sticky note. Time to learn what git calls it.

🗣 Git's word for a save point is a "commit." When someone says "commit your work," they mean: take the photo and write the sticky note. From here on, this course will say commit too.

One more thing is stamped on every photo: a receipt number. Git generates it automatically, and it looks like random letters and digits: f30f6b7.

That is exactly what they look like in real life. Once you start taking save points of your own, git will stamp a number like that on every single one, automatically.

🗣 The receipt number is officially called a "SHA." The full version is 40 characters long, but humans only ever use the first 7, like f30f6b7. It is just a name, like a receipt number or an order ID. You never memorize one, and you never type more than those first few characters.

Why does the receipt number matter? Because messages can repeat. The ID cannot. It is how git, and you, point at one exact photo with zero ambiguity.

5Writing good sticky notes

You will write thousands of these notes over the years. Six months from now, the note is the only clue about what a photo contains. A tiny habit today pays off forever.

Bad notes say nothing. Good notes describe the change so clearly that future you never has to open the photo to check.

# Notes that help nobody, including future you
stuff
fix
asdf

# Notes future you will be grateful for
Fix login button overlapping logo on phones
Add the May pricing table to the docs
Remove the broken newsletter signup form

Here is the rule of thumb. Your note should finish this sentence: "If you apply this commit, it will ..." "Fix login button overlapping logo on phones" completes it perfectly. "stuff" does not. That is the whole test.

6Check yourself

Q. What does a commit contain?

A commit photographs every file in the project, then staples on the sticky note: your message, who and when, and the link to the photo that came just before. It is never just the edited files, and never just a list of changed lines.

One more. Two commits in two different projects could both have the message "fix typo." How does git tell commits apart?

By the receipt number, the SHA. Git generates it automatically and it is effectively unique in the whole world. Messages can repeat all they like; the IDs never get confused.
🧠 If you remember one thing: a commit is a photo of every file in the project, plus a sticky note that says what changed, who took it and when, and which photo came just before.