Skip to content

Git in four commands (so the agent can never wreck your project)

You do not need to understand Git. You need four commands that make every change an AI agent makes reversible: save point, check, undo, go back.

By Nick

2 min read

Coding tools Intermediate
On this page
Time
Ten minutes
Cost
Free
Level
Intermediate

1. The four

Open a terminal (the window where you type commands) in the project folder.

git init                         # once per project: turn on save points
git add -A && git commit -m "x"  # make a save point (do this before every agent task)
git status                       # what has changed since the last save point?
git checkout .                   # throw away every change since the last save point

The second one is the habit. Before you hand an agent a task, make a save point. After it finishes and you are happy, make another. If you are not happy, the fourth one puts everything back in one second.

2. Let the agent set it up and keep the habit

Paste this into your coding agent in the project folder.

Check whether Git is installed and whether this folder is a Git repository. If not, set it
up, make a first commit of everything, and confirm. From now on, before you change any
file in a task, commit the current state first with a short message, and after a task
succeeds, commit again. Never force anything and never delete history. Tell me what you
did.

3. Trust the undo, not the agent

Everything on this site about coding agents assumes this is in place: one task at a time, the permission modes, all of it. Trust scales with how easy it is to undo, and this is what makes undo easy.

How you know it worked. git status says “nothing to commit” after a good task. If you ever see “detached”, “rebase” or “force” in an agent’s output, stop and ask what it is doing.

Common questions

Do I need GitHub?

No. Git is the tool on your computer; GitHub is a website for sharing. These four commands never leave your machine.

Is it not installed already?

On a Mac, typing git in the terminal offers to install it. On Windows, install Git for Windows. Or paste the prompt below and let the agent sort it.

What is a commit?

A save point. That is the whole concept you need. Everything else about Git is for teams, and you can learn it later or never.

What to do next

Related reading

Last reviewed 9 October 2026 by Nick.

Software changes fast. If something here is out of date, tell me and I'll fix it.

Get new guides by email

Occasional and practical. No spam, no hype, unsubscribe whenever.

Occasional practical guides from UncomplicateAI. You will get a confirmation email before anything else is sent. Unsubscribe any time. Privacy

You are not subscribed until you confirm the email. Unsubscribe any time.