Skip to content
zero2vibecodelearn vibe coding
Level 4 · Tools and version control 7 min Reviewed by the author · Aug 4, 2026

Commit history, and why it saves you

A series of commits is a series of points you can return to — which is what makes it safe to let an AI agent change a lot of code at once.

Level 4 · 0 / 4 lessons0%

One commit is a save. Several commits are a history — a line of points you can walk back along.

git log — read the history

git log
0a1b2c3 (HEAD -> main) first commit

Each entry has:

  • a hash like 0a1b2c3 — the commit’s unique name
  • a message — what you wrote with -m
  • on a real , also the author and the date

HEAD marks where you are standing right now, and main is the name of the branch you are on.

Note

This simulator prints one stand-in log line rather than your actual commits. On a real repository, git log lists every commit newest-first, and git log --oneline compresses each to a single line — which is how most people read it day to day.

Quick check

What is the hash in a git log entry for?

Why history is the point

A commit is not a backup of one file. It is a snapshot of the whole project at one moment. Returning to a commit restores every tracked file together, in a state that once worked.

That changes what is risky. Consider two versions of the same afternoon:

Without commits. You ask an agent to restructure the project. It edits fourteen files. Something breaks in a way you do not understand. Your options are to debug a change you did not write, or to start over.

With a commit first. Same afternoon, same breakage — except there is a known-good snapshot from ten minutes ago. You go back and try a smaller request.

The agent is equally capable in both stories. The difference is entirely whether you left yourself a way back.

Tip

The rule that costs nothing: git status should say “working tree clean” before you hand an agent a big task. If it does not, commit first. It takes ten seconds and it is the only reason you can be relaxed about the next twenty minutes.

Quick check

Before asking an agent to make a large refactor, what is the ten-second precaution?

Small commits, often

A commit costs nothing. Ten small ones are far more useful than one enormous one, because each is a place you can return to.

Compare:

add user login

against:

add user login, fix the header, update the readme, rename some variables

If the login work turns out to be wrong, the first history lets you undo exactly that. The second forces you to choose between keeping all four changes or losing all four.

Quick check

Why are small, frequent commits better than one large one?

Try it

Two commits, so you can see a history form:

  1. git init
  2. git add .
  3. git commit -m "add the homepage"
  4. git log — one entry.
  5. touch about.html — a new page.
  6. git status — one untracked file, and the rest is clean.
  7. git add about.html — stage only the new page.
  8. git commit -m "add the about page"
  9. git log

Look at step 6 carefully. Git is telling you precisely what has changed since the last snapshot — nothing more, nothing less. That is the report you want in front of you after an agent has been working.

Where this goes next

You now have the whole ground floor: moving around, reading and writing files, searching, pipes, and version control. That is the environment every runs in, and enough of it to read what one is doing over your shoulder.

The next course installs a real agent and points it at a real project.

Check your understanding

Answered 0/3
Mode:

What is a commit?

Why does committing often make AI-assisted work safer?

What makes a good commit message?

Finish the task in the terminal and answer the questions to complete the lesson.

📝 My notes

Saved automatically in this browser · shows up on the Notes page.

Task

Make one commit, add a new page, and make a second one. Then look at the history.

Tab complete · history · Ctrl+L clear · help commands

  • Not done: Look at the history with git log
  • Not done: You created a second page
  • Not done: Stage only the new page
  • Not done: Commit it with its own message

Lesson Q&A

What is a commit?

Each commit records the full state of the project, so returning to it restores everything at once.

Why does committing often make AI-assisted work safer?

The agent can change anything. The commit is what makes those changes reversible.

What makes a good commit message?

Git already records the files and the timestamp. The one thing only you can add is the reason.

What is the hash in a git log entry for?

Every commit gets a unique hash. That is how you name a specific point in history when you want to return to it.

Before asking an agent to make a large refactor, what is the ten-second precaution?

A commit is a cheap, complete, restorable snapshot. That is exactly what a risky change needs behind it.

Why are small, frequent commits better than one large one?

Granularity is the whole value. A commit that mixes four changes cannot be undone as one of them.

Move between lessons with · search with ⌘K