Git & repositories
project-final-v3-REAL
Alice ran a tiny online shop and kept her site in a folder called shop-final. When she asked an AI to redo the checkout, she copied it first and named the copy shop-final-v2, then v3, then final-REAL. Two weeks later a customer reported that discount codes no longer worked. Alice opened all four folders and couldn't tell which one had last worked or what exactly had changed between them. Then her laptop wouldn't turn on, and everything lived only there.
- Git can record deliberate save points: what changed, who saved it, when and why. Commit & push, later in this lesson, shows how to make one.
- A copy of a folder can't show which lines changed or let you throw away a risky idea.
- A repository can later be copied to a site like GitHub, so a dead laptop isn't the only copy.
- History is permanent, so never save passwords or keys in a repo.
Folder copies are replaced by Git save points
Dos and don'ts
- Check the repository before each AI session so you know its starting state.
- Later in this lesson: copy the repository to GitHub so one laptop isn't your only copy.
- Rename folders as your version history.
- Save keys or passwords in the repository.
Why copies aren't enough
A copy of a folder shows what the project looked like then. It can't clearly show which lines changed since Tuesday, who added a strange rule, or how several versions relate.
What a repository is
Example: a folder with a hidden .git directory is a repository; without it, git status says "not a git repository." When Git is switched on for a project folder, that folder becomes a repository. Your normal project files are the working copy. A hidden .git folder stores Git's history and settings; don't edit it by hand. Git doesn't automatically publish the project or send it anywhere. Git keeps history on your computer; GitHub (or GitLab, Bitbucket) is a host that stores a copy online so others can clone, review and open pull requests.
Check before the AI touches anything
An AI agent edits whatever folder it was started in. If that's the wrong folder, or a folder Git isn't watching, its changes land where nothing can undo them. So at the start of every session, ask the agent two things: which folder is it in, and is Git switched on there? Then have it show what has changed since the last save point. Those few seconds are what make save points work: you can only go back to a state you knew about.
One rule from day one: a password or key saved into a repository stays in its history even after you delete it. Never put one there.
Run git status and git rev-parse --show-toplevel in my project folder. Tell me which of the three answers I am looking at: no repository, clean, or uncommitted changes. If files changed since the last commit, show me what changed before we do anything else.
Dos and don'ts
copy the folder and call it final-v2
Before the AI edits anything, ask it which repository it is in and what has changed since the last save point.
Example
Check whether my project folder is already a Git repository by looking for the hidden .git folder and running git status. If it is not, explain what git init would create and what it would leave alone, then run it only after I say yes, and show me the status afterwards.
Paste into your agent inside a project folder. Prompts that say "this project" are for the app you build in the Lab, or any app you already have. No project yet? Read them now and paste them later, in the Lab.
I am in my project folder. Tell me whether Git is switched on here and show me how you checked. If it is not, explain what git init would and would not do, but do not run it yet.
Before the AI edits files, confirm which repository I am in, show its root folder and current status, and explain what each status section means. Do not save or change anything yet.
Show me the hidden .git folder without opening or editing its contents. Explain in one sentence what Git stores there and what remains in my working copy.
Watch
Git watches a project folder and remembers save points.