Skip to main content
Technical Enough
Next: Environments

Git: the undo that makes AI edits safe

Chapter 6 of 7 in The Software Map · 17 min

You promised the club a pace calculator, and at 10:14 pm you hand the job to your agent. The site already runs on your laptop with its home, trails, RSVP, and tidy pages. The agent proposes touching fourteen files, four of them new, and you have never opened most of the rest. You approve, and filenames scroll past faster than you can read them. Halfway through, the trails page comes up blank. You press Ctrl+Z, but undo cannot help here. Undo works inside one editor window (the app where you change a file's text) and reverses only your own last keystrokes in one file, and no key on your keyboard can reverse what the agent is rewriting across fourteen files. One save point made before the session would have let you put the whole project back, and you had not made one.

Undo for the whole project, not one file

Git is the change-tracking program most software projects use. It keeps every version of every file, with a one-line note on each version, and it can bring any of them back. The undo you reached for covers one file, and git covers every file in the folder for as long as the project exists.

Without git, people keep versions by saving renamed copies, in a folder that looks like this:

Final.docx
Final_v2.docx
Final_FINAL.docx
Final_FINAL_use_this_one.docx

Nothing in that folder says what changed between two copies. Git keeps a note for every version, and it is already switched on in most project folders an agent creates.

A repository is a project folder that git tracks; builders shorten it to repo. Your running-club folder becomes one the moment git is switched on inside it, and from then on git can show every edit since the last save point, yours or the agent's.

Save points, branches, and restoring

A commit is a snapshot of every file at one moment, with a one-line note saying what changed, and in this course we call it a save point. Like a save point in a game, it marks a spot you can return to, so if something goes wrong you lose only what happened since then.

The history is the list of save points, newest first, with each note beside its snapshot. A branch is a separate line of save points for an experiment, like a side track off a railway's main line. The main line stays as it was while you experiment, and it changes only if you keep the result.

To restore means to put a file, or the whole project, back to a save point. Here is the running-club history as it would look with a save point made before the agent session.

The drawing lays the save points out oldest to newest, left to right. The agent session's save point is marked "trails page blank", and the arrow marked "restore" goes back to the save point called "before pace calculator". When you restore to that save point, the two newer save points ("agent session" and "fix rounding") drop off the line, though git still keeps them for a while in case you change your mind. That is fine: you chose an earlier state, and the next save point you make starts the line again from there.

Git is undo for the whole project. It records every change to every file, so any earlier version can be put back.

Ask the agent what changed

Before you put anything back, ask the agent what it changed during the session. A diff is the before-and-after of one change, the lines removed and the lines added, file by file. Here is the one for the page that went blank.

On the card, the line marked "what was" shows the old text, and the line marked "what is now" shows the new text. You never type a command to get this view; you ask the agent, and it prints one card like this for each file it changed. With fourteen cards to read, ask for the list of changed files first and open only app/trails/page.js, the one behind the blank page.

These are the three requests you type to the agent, in the order you use them:

  1. Before the session: "Make a save point before you start; call it 'before pace calculator'."
  2. When something looks wrong: "Show me what changed since the save point."
  3. To restore: "Put the project back to the save point 'before pace calculator'."

The agent turns each request into the right git command and runs it in the terminal.

Make the save point first

An agent edits faster than you can read its plan, and in a long session it changes files you have never opened. You cannot review every line as it scrolls past, so you have to make the project safe before the session starts.

Make a save point before an agent edits anything. After that, the worst case is putting the project back and asking again with better instructions.

With that save point in place, typing the third request when the trails page went blank would have put the project back: the files the agent created would be gone, and every edited file would hold its earlier text. You would then ask again, with one more instruction: leave app/trails/page.js alone.

The objection: my tool can already rewind a session

Claude Code, the AI coding tool we use in this course, records the state of your files as a session runs and can rewind to an earlier point. Other coding tools do the same. A checkpoint is a tool's own record of one session, the tool's private notes on what it changed. So why learn git at all?

A checkpoint records what one tool changed in one session; git records what the whole project looked like at every save point, whoever made the change.

  • Checkpoints stay behind with the tool when you switch tools, while the git history is stored inside the folder, so whatever tool you use next has it.
  • Checkpoints cover the agent's edits but not yours; git records a line you changed like any other change.
  • Checkpoints are private to the tool; the git history is what collaborators read and what hosting services use to put your site online.

A tool's checkpoint records one session inside one tool; git is the project's permanent record, and it is what collaborators and hosting services read.

Git on your laptop, and a copy online

Git keeps the history on your laptop, inside the project folder. GitHub is a website that keeps a copy of your history online, a backup of the whole project. Other websites do the same job, but most shared code is stored on GitHub. This is the local and remote split from Where software lives, applied to your own history.

To push means to send your save points up to that online copy. When the agent offers to push after a session, say yes: then if your laptop dies, you lose the hardware but not the project. To clone means to copy the whole history down onto another machine, so a new laptop or a collaborator starts with every save point you ever made. In Environments: why it works on your machine and breaks online, you put the site the club uses onto the internet from that same online copy.

Try it now

This drill takes about ten minutes; the no-setup path costs nothing, and the tooled path costs a few cents of usage.

No setup: Open GitHub in a browser and search for microsoft/vscode, a large public repository; no account is needed. Above the file list, a clock icon with a number beside it shows how many save points the project has. Click it to open the history, newest first, one row per save point with its note, author, and time. Expect insider shorthand in the notes.

With your tools: Open Claude Code in the running-club folder and type: "Make a save point before you start; call it 'before pace calculator'." The agent switches git on if the folder needs it and reports the save point by its note. Ask for a small change to the trails page, then type "Show me what changed since the save point" and read the diff for app/trails/page.js. Then type "Put the project back to the save point 'before pace calculator'", refresh the page, and check that your change is gone. In Codex or Cursor, the same three requests work, and a side panel lists every file the agent changed. If nothing is installed yet, The Setup Clinic gets you to that first save point.

Either way, add one line to the idea file, and on the tooled path keep a first save point in the running-club folder. The line: "Before every agent session: save point. To undo: put it back to [name]."

Chapter Summary

  • Git is undo for the whole project: it records every change to every file, so any earlier version can be put back.
  • A repository is a project folder that git tracks, and a commit, which we call a save point, is a snapshot of every file at one moment with a one-line note. The history is the list of save points, newest first; a branch is a side track for an experiment; to restore means to put a file or the whole project back to a save point.
  • A diff is the before-and-after of one change, lines removed and lines added, file by file, and you ask the agent to show it rather than typing a command.
  • Make a save point before an agent edits anything; after that, the worst case is putting the project back and asking again with better instructions.
  • The three requests you type are: make a save point and name it, show me what changed since the save point, and put the project back to the save point.
  • A save point covers only files in the project folder. It never covers the records real users have entered, the emails a tool has sent, or the money a payment service connected to your site has moved, so an agent that can touch any of those needs limits too.
  • A tool's checkpoint records one session inside one tool; git is the project's permanent record, and it is what collaborators and hosting services read.
  • Git keeps the history on your laptop, GitHub holds a copy online, push sends save points up, and clone copies the whole history down.
  • On the tooled path you now hold a first save point in the running-club folder, and the idea file carries the rule: save point before every agent session.
  • Next, in Environments: why it works on your machine and breaks online, you put the site online for the club and see why a project that runs on your laptop can still break there.

Sources

  • Business Insider and Fortune reporting on the Replit coding agent deleting a startup's database (July 2025).
  • Git documentation, git-scm.com (last verified July 2026).
  • GitHub documentation on commits and viewing a repository's commit history (last verified July 2026).
  • Anthropic Claude Code documentation on checkpoints and rewinding a session (last verified July 2026).