← Back to Mission Control

Scanning for Changes

8 min read

Git Diff

Mission Phase 12 • Difficulty: Beginner

Detecting System Modifications

The git diff command is your scanner—it shows exactly what changed between different states of your files. Essential for reviewing work before committing.

Basic Diff Usage

See unstaged changes:

git diff

This compares your working directory to the staging area.

See Staged Changes

git diff --staged

Shows what's in the staging area vs. last commit.

Reading Diff Output

diff --git a/navigation.js b/navigation.js
index 3a8f2c1..7b9d4e2 100644
--- a/navigation.js
+++ b/navigation.js
@@ -10,7 +10,7 @@ function calculateCourse() {
     const distance = Math.sqrt(dx*dx + dy*dy);
-    const speed = 1000; // meters per second
+    const speed = 1500; // increased for faster travel
     return distance / speed;

Compare Specific Files

git diff navigation.js

Compare Commits

git diff commit1 commit2
git diff HEAD~2 HEAD    # Compare 2 commits ago to now

Compare Branches

git diff main feature-branch

Useful Diff Options

Why Use Diff?

Next: Reviewing History

You can now see what changed. Next, we'll explore git log to review your complete mission history.