Set up git for your project

The prompt from the reel. Paste it into Claude Code and it'll set up git, save before every change it makes, and keep a copy of your saves on GitHub.

How to use it

  1. Open your project in Claude Code (Cursor, Codex or any AI coding tool that can read your files works too).
  2. Copy the prompt and paste it in.
  3. When it asks about GitHub, make a free account at github.com if you don't have one. The repository it creates is private, so only you can see it.
  4. If something breaks later, tell Claude "go back to the last save". It can list your saves and bring any of them back.

The prompt

Set up git for this project so every change can be undone, and keep a copy of my saves on GitHub.

1. Check that git is installed (git --version). If it isn't, stop and tell me how to install it on my computer (on a Mac: xcode-select --install; on Windows: git-scm.com).
2. If this folder isn't a git repository yet, run git init and name the main branch main. If it already is one, tell me and don't redo anything.
3. Create or update .gitignore so it leaves out things that should never be saved: node_modules, build output (dist, build, .next), log files, OS files like .DS_Store, and every .env file. Add a .env.example with the variable names and no values.
4. Before the first save, check the files about to be saved for secrets: API keys, tokens, passwords, private keys. If you find one, stop and show me where it is instead of saving it.
5. Make the first save: commit everything with the message "First save".
6. Add this rule to CLAUDE.md in the project root (create the file if needed, and add the same lines to AGENTS.md if there is one), so it holds in every future session: "Before you change any file, run git status. If there are unsaved changes, commit them first with a short message that says what they are. After a change works, commit it with a message that says what you changed. Never run git reset --hard, git push --force or anything else that deletes saves without asking me first."
7. Put a copy on GitHub. If the GitHub CLI (gh) is installed and signed in, create a PRIVATE repository for this project and push to it. If it isn't, tell me the exact steps (install gh, run gh auth login) and wait. Never make the repository public.
8. Finish by showing me my saves (git log --oneline) and how to go back: how to undo one file, and how to bring the whole project back to an earlier save without losing the newer ones.

Explain each step in plain words as you go. I'm new to git.

Why save before every change

An AI coding tool can change dozens of files in one go. If it saves first, any change it makes is one step away from undone, and you can say "go back" without having to remember what the app looked like before. Without a save, the only copy of your working app is the one it just changed.

The game, decoded

The save button
A commit: a snapshot of every file in your project at that moment. Each one takes about 2 seconds.
Losing all 3 hearts
A change that breaks your app, like Claude turning 14 screens into a white page.
Loading the save
Going back to an earlier commit. The project is exactly how it was when you saved.
Saves on your laptop
The hidden .git folder inside your project. If the laptop dies, the saves go with it.
A copy on GitHub
A private copy of all your saves online, safe even if your laptop isn't.
Linus Torvalds, 2005
He wrote git to manage the code of Linux. Most software in the world is saved with it today.

Keep your keys out of your saves

Anything you commit stays in the history, even after you delete it. The prompt checks for secrets before the first save and keeps .env files out. To find keys already in your code, see the API key prompt.