Saving Your Work
What 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 (checkout, 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.
Worked Example: Reviewing AI Changes Before Committing
Here’s a realistic scenario. You asked Claude Code to update your project, and now you want to review what it did before saving:
# You already have a clean commit# Claude Code modified several files# Step 1: See which files were touchedgit status# modified: index.html# modified: style.css# new file: 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 reverts the file to its last committed version. The changes are gone.
Undo All Changes Since Last Commit
git restore .This discards unstaged changes in all tracked files. Use with caution — all uncommitted changes to tracked files are lost. 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, do a quick git add . && git commit -m "Save point before changes". This guarantees you can always get back to a working state.
🔍git restore vs. git checkout
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 has been local — saved on your computer only. To back up your work and share it, push to GitHub.
The steps below walk through the manual setup. Lesson 4 covers a one-command alternative using the GitHub CLI (gh repo create --push) that handles all of this automatically. If you prefer the faster path, skip ahead to Lesson 4 and come back here only if you need the manual method.
Step 1: Create a GitHub Repository
- Go to github.com and sign in (create an account if needed)
- Click the + button, then New repository
- Name it (e.g.,
my-project) - Keep it Public or Private — your choice
- Don’t add a README, .gitignore, or license (you already have files)
- Click Create repository
Step 2: Connect Your Local Project to GitHub
GitHub will show you commands. Copy and run them:
git remote add origin https://github.com/YOUR-USERNAME/my-project.gitgit branch -M maingit push -u origin mainLet’s break these down:
git remote add origin— tells git where to upload (the GitHub URL)git branch -M main— renames your branch to “main” (the convention)git push -u origin main— uploads your commits to GitHub
Step 3: Future Pushes
After the initial setup, pushing new work is just:
git pushOne command. Your code is backed up in the cloud.
Two common issues:
Authentication error: GitHub no longer accepts passwords. Run gh auth login (from the GitHub CLI) to authenticate via your browser, or set up a Personal Access Token at github.com/settings/tokens.
Rejected push (remote has new changes): Run git pull --rebase origin main to incorporate the remote changes, then git push again.
📊In Your Field: MIS / Businessclick to expand
Think of GitHub as your project’s cloud backup with collaboration built in. In business contexts, having your work on GitHub means a colleague can pick up where you left off, your supervisor can review progress, and nothing is lost if your laptop dies. For team projects — dashboards, automation scripts, report templates — GitHub becomes the single source of truth that everyone works from.
🏛️In Your Field: Government / State Devclick to expand
Some government environments restrict access to public GitHub. Your agency may use GitHub Enterprise, GitLab, or Azure DevOps instead. The git commands are identical — the only difference is the URL in git remote add origin. Check with your IT team about which hosting service is approved. The key point remains: get your work off your local machine and into a backed-up, shared repository.
The Daily Workflow
Here’s the complete workflow you’ll follow for every project:
# 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 gemini, codex, etc.> "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 uncommitted 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. - Undo is always available.
git restore .reverts tracked files to the last commit.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 95% of what you’ll do 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?