Reading History, Diffs, and Repository State
What This Concept Is
Git fluency is mostly inspection fluency. Before you fix, merge, rebase, reset, or recover, you need to read the repository state correctly. The core inspection tools are:
git statusgit diffgit diff --stagedgit loggit show
Why It Matters Here
People often break Git history by acting too early. Inspection commands are what let you answer:
- what changed?
- what is staged?
- what commit am I on?
- what happened recently?
- what branch shape am I working with?
If you can answer those cleanly, most "Git problems" become smaller.
Concrete Example
A compact inspection sequence looks like this:
git status
git diff
git diff --staged
git log --oneline --graph --decorate --all -5
git show HEAD
That gives you:
- current file state
- unstaged changes
- staged changes
- recent branch/merge shape
- the exact content and metadata of the current commit
Common Confusion / Misconception
Misconception: git log is only for old history.
Correction: git log is a live inspection tool. A short graph view often tells you more than a GUI branch diagram.
Misconception: git status is enough by itself.
Correction: status tells you where changes are. diff and show tell you what the changes actually are.
How To Use It
Use inspection in layers:
git statusfor the summarygit difforgit diff --stagedfor exact line-level changesgit log --oneline --graph --decorate --allfor history shapegit show <commit>for one commit in detail
Practical rule:
- never merge, rebase, or reset before you can explain the current state in one sentence
Check Yourself
- Which command best answers "what is staged right now"?
- Which command best answers "what changed in this specific commit"?
- Why is
--graph --decorate --alluseful during branch work?
Mini Drill or Application
Build a three-commit repository and then:
- modify a file without staging it
- stage another file
- run
status,diff, anddiff --staged - run
git log --oneline --graph --decorate --all - write one short explanation of what is modified, staged, and already committed
If your explanation is inaccurate, repeat the drill.