Skip to content

Latest commit

 

History

History
125 lines (72 loc) · 2.53 KB

File metadata and controls

125 lines (72 loc) · 2.53 KB

🔎 git diff (See Changes)


🎯 What It Does

Shows differences between versions.


🧪 Command

git diff

📸 Visual (Diff Comparison)

Image

Image

Image

Image

Image

Image


🧠 Mental Model

git diff = compare snapshots


🏗 Internal Architecture

Git compares:

Working Directory ↔ Index ↔ HEAD

🔬 Diff Types

1. Working vs Staging

git diff

2. Staging vs Last Commit

git diff --staged

🧩 Example

Before:

Hello

After:

Hello World

Diff:

+ World

🧠 How Git Computes Diff

Git uses algorithms (like Myers diff) to:

  • find added lines
  • find removed lines
  • show minimal changes

⚠️ Common Mistake

Not checking diff before commit.

👉 Leads to wrong commits


🧠 Why This Matters

Because:

  • helps debugging
  • shows exact changes
  • prevents mistakes

🧠 Memory Trick

diff = what changed


➡️ Next Step

👉 12-ignore-files.md