Yeswanth Madasu

Day 06/13 of Git 101 Series

Status, Log, Diff


Concept Explanation

Status tells you what changed.
Diff tells you how it changed.
Log tells you the story of what changed and when.


Commands

git status

Shows tracked, untracked, staged, unstaged.
In short, answers: what is going on in my repo right now.

git diff

Shows line-by-line changes between working directory and index.

git diff --staged

Shows changes that are staged but not yet committed.

git log

Shows commit history.

git log --oneline --graph --decorate

Displays a clean, human-friendly history view with branches and commit messages.


Example

You edited index.html and added a new utils.js.

Run:
git status
You’ll see:

Stage index.html:
git add index.html

Check what you staged:
git diff --staged

Commit your changes:
git commit -m "Fix header bug; add utils skeleton"

Review history:
git log --oneline --graph --decorate


Real World Use Case

You’re about to push changes to a shared repo.
Nobody wants a midnight message from a teammate asking why your commit broke the build.

Before pushing, you:


Under-the-Hood Explanation

Git doesn’t compare raw files.
It compares snapshots.

Git internally works with three layers:

  1. Working directory
  2. Index (staging area)
  3. Commit tree stored in .git/objects

When you run git diff, Git compares:
Working directory vs Index
Shows what changed but isn’t staged.

When you run git diff --staged, Git compares:
Index vs Last Commit
Shows what you staged but haven’t committed.