Never lose a change again.
You've got the terminal down. Next is Git — the tool that remembers every version of your project so you can always see what changed, undo it, or go back. This is what makes it safe to let an AI agent touch real files.
What even is Git?
Two words that get used interchangeably but mean different things.
Is a program on your computer. Every time you tell it to, it saves a snapshot of your project — what changed, who changed it, and when. Think of it as a save-history for your whole folder, not just one file: your own version control, and your own Google Drive for code, running locally.
Is the cloud service you send that history to — so it's backed up somewhere that isn't just your laptop, and so other people (or other machines) can see it too. Git is the tool; GitHub and GitLab are places to put what it made. (This project itself lives on GitLab.)
The three states
Every change you make passes through three stages, in order. This is the one idea worth really understanding — everything else builds on it.
You edited a file. Git noticed. Nothing is saved yet — it's just sitting there, changed.
git addYou've told Git "this change is going in the next save." Nothing's permanent yet — you can still change your mind.
git commitPermanently in the history now, with your name and a timestamp attached. This is a real save point you can always come back to.
you@laptop gravity % git status On branch main Changes not staged for commit: modified: notes.txt you@laptop gravity % git add notes.txt you@laptop gravity % git status On branch main Changes to be committed: modified: notes.txt
Try it: your first commit
Same flow, two ways to do it — the terminal, and a GUI. Pick whichever clicks for you; they end up in the exact same place.
you@laptop gravity % echo "hello" > notes.txt you@laptop gravity % git add notes.txt you@laptop gravity % git commit -m "add notes" [main 4f2a1c9] add notes 1 file changed, 1 insertion(+) you@laptop gravity % git log commit 4f2a1c9 Author: you Date: just now add notes
See your history — gitk & git gui
There are dozens of Git apps out there. These two are the simplest, and they already came with Git — or one command away.
brew install git-gui
Branches are pointers, not copies
The single most common misunderstanding about Git — worth getting right early.
A branch is not a second copy of your
whole project. It's just a little sticky note — a name, like
main — stuck onto one specific commit. When you make a
new commit, Git just moves that sticky note forward to point at it.
That's what makes branches fast and cheap: creating one doesn't copy any files, it just adds another sticky note somewhere in the same history you already have.
Three commits, one pointer — main just labels the newest one.
Going back in time, carefully
If a branch is a pointer, moving it backward means going back to an older save — and that's exactly what git reset --hard does.
git reset --hard can throw work away — with no undoIt moves the branch pointer to wherever you tell it, and makes your files match that older commit exactly — including deleting any uncommitted changes sitting in the unstaged or staged states from earlier in this page. If it wasn't committed yet, it doesn't survive.
The habit that keeps you safe: run git status first, every
time. If it says anything is unstaged or staged, deal with that (commit it, or be sure
you don't need it) before you reset anything.
Local vs. the cloud
Your laptop's idea of "what's on GitHub" is a snapshot from the last time you checked — not a live view. It goes stale quietly.
git fetch — recommendedGoes and checks what's actually on GitHub or GitLab, downloads anything new — but doesn't touch your files. You look at what changed first, then decide what to do about it. Look before you leap.
git pull — use with caution
Does a fetch, then immediately merges whatever it found into your work, with
no pause to look first. Sometimes that's fine; sometimes it's a surprise merge you
weren't ready for. This project's own recommendation: reach for
git fetch on purpose, every time, and skip
git pull.
This is what makes AI safe to hand the keys to.
When an AI coding agent edits real files, Git is what lets you see exactly what it
touched (git status, git diff),
decide whether to keep it, and know you're never more than one commit away from where
you started. That's the whole safety net — and you just learned how it works.