See what changed
Find the differences
⏱ Est. ~7 min
01 · Read
Before committing, you usually want to see what you actually changed. git diff compares your current files to the last commit, line by line — additions are green, deletions are red.
💡 Picture thisUsing git diff is like putting two photos side by side and playing "spot the difference." git explicitly highlights what was added, removed, and changed, so you can review your work before you commit.
Key points
- git diff shows the differences between "unstaged changes" and "the last commit"
- Added lines start with + (green), deleted lines start with - (red)
- Checking the diff before every commit catches mistakes early
02 · Terminal exercise
To see changes, we need a git repo with a commit so there's something to compare against.
(This section is interactive — please enable JavaScript.)
03 · Terminal exercise
Stage all the files and make your first commit.
(This section is interactive — please enable JavaScript.)
04 · Terminal exercise
Make the first commit so git has a baseline to compare future versions against.
(This section is interactive — please enable JavaScript.)
05 · Quiz
By default, what is git diff comparing?
- Your current files vs. the last commit
- Two different branches
- Two different files
- Local repo vs. GitHub
06 · Terminal exercise
Now let's modify the file. Add a new line to app.js.
(This section is interactive — please enable JavaScript.)
07 · Terminal exercise
Now use git diff to see exactly what's changed since the last commit.
(This section is interactive — please enable JavaScript.)
08 · Fill in the blank
To see what you've changed since the last commit (before staging), you run git ___.
Other lessons in this chapter
⚠ The full interactive experience needs JavaScript. Please enable it and reload.
※ This is an independent Traditional Chinese teaching project — not an official Anthropic product. Claude™ is a trademark of Anthropic, PBC.