Saving Your Work
Last reviewed
BeginnerWhat you'll learn
~20 min- Use git status, git log, and git diff to understand your project state
- Undo mistakes with git restore and git reset
- Push your local repository to GitHub for backup and collaboration
- Follow the daily orchestrator workflow: status, work, add, commit, push
By the end of this lesson, you’ll know how to inspect your project’s history, undo mistakes, and back up your work to GitHub — completing the full version control toolkit you need as an AI orchestrator.
The Mental Model: Your Project’s Dashboard and Time Machine
In the last lesson, you learned to save snapshots with commits. Now you need two more abilities:
- A dashboard — so you can see what’s happening in your project right now (what changed? what’s saved? what’s pending?)
- A time machine — so you can look at past snapshots and, when needed, go back to one
Git gives you both. Three commands make up your dashboard (status, log, diff), and a couple more give you the time machine (restore, reset).
Your Dashboard: Three Inspection Commands
git status — What’s Changed Right Now?
git statusThis shows:
- Untracked files — new files git doesn’t know about yet
- Modified files — existing files that have changed
- Staged files — files ready to be committed
Run this frequently. It’s your most-used command — the first thing you type when you sit down to work, and the command you check after every AI interaction.
git log — What Have I Committed?
git log --onelineThis shows a list of your commits, newest first:
a1b2c3d Add contact form with validatione4f5g6h Update homepage hero sectioni7j8k9l Initial commitEach line shows a unique commit ID (the letters/numbers) and your commit message. The --oneline flag keeps it compact.
If the output is long, git will open a viewer (called a pager). Use your arrow keys to scroll, and press q to quit and return to your terminal. This catches many beginners off guard — just remember: q to quit.
Look at that log. Can you tell what the project looks like at each point? Good commit messages make your log a readable story of your project. Bad messages (“stuff,” “update,” “fix”) make the log useless. When you need to revert, a clear log is the difference between finding the right commit in seconds versus guessing.
git diff — What Exactly Changed?
git diffThis shows line-by-line what has changed in your unstaged files. Lines starting with + were added, lines starting with - were removed. If you have already staged changes with git add, use git diff --staged to see those instead.
<h1>Welcome</h1><h1>Welcome to My Portfolio</h1>This is especially useful after an AI tool makes changes. Before you commit, run git diff to review exactly what the AI modified. Think of it as proofreading before you sign off.
Read your history
In your own terminal, inside your ai-class folder, run:
git log --onelineEach line is one checkpoint: a short ID and the message. If you have only one or two, ask your agent to save a checkpoint after each small change and look again.
Worked Example: Reviewing AI Changes Before Committing
Here’s a reference session walkthrough after you ask Claude Code to update your project and want to review what it did before saving (in daily work, you can run these commands yourself or ask your agent to show the diff and save a checkpoint for you):
# You already have a clean commit# Claude Code modified several files# Step 1: See which files were touchedgit status# Changes not staged for commit:# modified: index.html# modified: style.css# Untracked files:# utils.js
# Step 2: See the actual changesgit diff# Shows line-by-line changes in index.html and style.css# (New files won't appear in git diff. Stage them first with# git add, then use git diff --staged to see their contents.)
# Step 3: Everything looks good — stage and commitgit add .git commit -m "Add utility functions and update page layout"
# Step 4: Verify the commit is savedgit log --oneline# f8a9b1c Add utility functions and update page layout# a1b2c3d Previous commit message...This review habit — status, then diff, then add and commit — takes 30 seconds and prevents you from accidentally saving broken changes.
🧬In Your Field: Biotechclick to expand
When an AI tool modifies a data analysis script, git diff becomes your peer reviewer. You can see exactly which lines of your analysis changed before you commit. Did the AI accidentally remove a normalization step? Did it change a p-value threshold? Reviewing the diff catches these issues before they become buried in your project history.
Your Time Machine: Undoing Mistakes
One of git’s greatest powers is letting you undo things. Here are the commands you’ll actually need:
Undo Changes to a Specific File (Before Committing)
git restore filename.txtThis throws away the file’s unstaged changes, putting it back to its last committed version (or to the version you staged with git add, if you staged it). Those changes are gone.
Undo All Unstaged Changes
git restore .This discards unstaged changes in all tracked files. Use with caution: those changes are lost. Anything you already staged with git add survives; to discard staged changes too, run git restore --staged --worktree .. Untracked files (brand-new files the AI created) remain; remove them manually or with git clean -fd.
Undo the Last Commit (Keep the Changes)
git reset --soft HEAD~1(HEAD means “where we are right now,” and ~1 means “go back one step.” So HEAD~1 = the commit before the current one.)
This undoes the commit but keeps your file changes. Useful when you committed too early or with the wrong message.
Before running any AI tool or making big changes, ask your agent to save a quick Git checkpoint. This guarantees you can always get back to a working state.
Undo an edit safely
Ask your agent to save a checkpoint first. Then ask it to make a small change you do not want, and finally ask:
Throw away that last change and put the files back to the last checkpoint.
Check with git status in your own terminal. It should report a clean working tree.
🔍git restore vs. git checkoutclick to expand
Git 2.23+ introduced git restore as a clearer alternative to the older git checkout for undoing changes. We use git restore in this course because it does exactly one thing and is less confusing. If you see git checkout . or git checkout -- filename in older tutorials or AI-generated suggestions, they do the same thing as git restore. Both work fine.
Pushing to GitHub
So far everything is saved only on your computer. Backing it up to GitHub needs an account first, so that is the next lesson. In Lesson 4 you will ask your agent to publish the project for you.
The Daily Workflow
Here’s a reference walkthrough of the complete cycle you’ll follow for every project (in daily work, you can either run these commands in your terminal or ask your agent to run checkpoints and pushes for you):
# Start of work sessiongit status # Check current state
# Save point before AI workgit add .git commit -m "Save point: working homepage"
# Make changes (AI tools, manual editing, etc.)claude # or agy, codex, copilot> "Add a navigation bar to the site"
# Review what changedgit status # See which files were touchedgit diff # See line-by-line changes
# Save your workgit add .git commit -m "Add responsive navigation bar"
# Back up to GitHubgit pushRepeat this cycle as many times as you like during a session. Each commit is a save point. Each push is a backup.
Quick Reference
| I want to… | Command |
|---|---|
| See what’s changed | git status |
| See commit history | git log --oneline |
| See exact line changes | git diff |
| Stage all changes | git add . |
| Commit changes | git commit -m "message" |
| Push to GitHub | git push |
| Undo unstaged changes | git restore . |
| Undo last commit (keep files) | git reset --soft HEAD~1 |
When Things Go Wrong
Use the Symptom → Evidence → Request pattern: describe what you see, paste the error, then ask for a fix.
Key Takeaways
git statusis your most-used command. Run it before and after everything — it shows you what git sees.- Review before committing. Use
git diffto check what an AI tool actually changed before you save it. - A commit is your way back.
git restore .throws away unstaged changes in tracked files (anything you staged survives;git restore --staged --worktree .discards both).git reset --soft HEAD~1undoes a commit but keeps your files. - Push to GitHub for backup. After the one-time setup,
git pushbacks up your work in seconds. - The daily cycle is simple: status, commit, work with AI, review, commit, push. A small set of commands you will repeat:
status,diff,add,commit,push.
You now know enough git for most of what you’ll do day to day as an orchestrator. There’s much more to git (branches, merging, rebasing), but you can learn those when you need them, and even then you can ask your AI tool to help you with the commands.
You ran git diff and it shows no output, but git status shows modified files. What's most likely happening?
What's the correct order for the daily AI orchestrator workflow?