# Git safety net

Git is why you can let an agent loose on your project without fear. Every commit is a save point you can go back to. You don't need to master it. You need five ideas, and your agent can run the commands for you.

## The five ideas

1. **Repo:** your project folder, with a memory of every saved version.
2. **Commit:** a save point with a note saying what changed. Small and often.
3. **Branch:** a parallel copy to try something in, without touching the working version (`main`).
4. **Push:** send your commits to GitHub, so they're backed up and your host can deploy them.
5. **Pull request (PR):** a proposal to merge a branch into `main`. You review it, then merge it. On most hosts it also gets a preview link.

## The habit

- [ ] Before a task: everything is committed (`git status` says "nothing to commit").
- [ ] For anything bigger than a tweak: start a branch.
- [ ] After a task that works: commit it with a clear message.
- [ ] End of the session: push.

## Saying it to your agent

You don't have to type git commands. Say:

- "Commit this with a clear message."
- "Start a new branch called [name] for this task."
- "Show me what changed since the last commit." (it'll run `git diff`)
- "Push this branch and open a pull request."
- "This last change broke things. Undo it back to the last commit." Then check it did.

## When it goes wrong

- **The agent made a mess and nothing's committed:** "Throw away all uncommitted changes" (`git restore .`). Everything since your last commit is gone, and that's the point.
- **A bad commit:** "Revert the last commit." This adds a new commit that undoes it, so nothing is lost.
- **Something odd happened:** "Explain what state my repo is in, in plain English, before doing anything."
- **Never** let it force-push or rewrite history on `main` unless you understand why. Ask first.

## Commit messages that help future-you

| Unhelpful | Helpful |
| --- | --- |
| fix | Fix the attendance list not wrapping on phones |
| updates | Add dark mode that follows the system setting |
| wip | Start the sign-up page (form only, not wired up yet) |
