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:
index.htmlmodified (unstaged)utils.jsuntracked
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:
- Run
git statusto ensure you’re committing only what you intend. - Run
git diffto confirm your changes are correct and not leftover debug lines. - Run
git logto check if your commit messages actually make sense.
Under-the-Hood Explanation
Git doesn’t compare raw files.
It compares snapshots.
Git internally works with three layers:
- Working directory
- Index (staging area)
- 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.