The Hook (The "Byte-Sized" Intro)
git status is the most underrated command in Git. Senior developers run it between every other command. It's your dashboard, your compass, and your sanity check — and it will never lie to you. If you're lost, run git status. If you're not lost, run git status anyway.
📖 What is git status?
git status reports the current state of your working tree and staging area. It tells you what's changed, what's staged, and what Git doesn't know about yet — all in one glance.
Conceptual Clarity
git status answers three questions simultaneously:
| Question | Section in Output | What It Means |
|---|---|---|
| What's ready to commit? | "Changes to be committed" | Files in the staging area |
| What's changed but not staged? | "Changes not staged for commit" | Modified tracked files |
| What's new and untracked? | "Untracked files" | Files Git has never seen |
File lifecycle in Git:
- Untracked → Git doesn't know this file exists
- Tracked, unmodified → Git knows it, nothing changed (doesn't appear in status)
- Tracked, modified → You changed it, but haven't staged the changes
- Staged → Changes are selected for the next commit
- Committed → Saved in history (disappears from status)
Real-Life Analogy
git status is like the status board at an airport:
- Staged = "Boarding" (ready to go)
- Modified = "Check-in open" (needs action)
- Untracked = "Not on any flight" (unknown to the system)
- Clean = "All flights departed" (nothing pending)
Visual Architecture
Why It Matters
- Prevents accidents: See exactly what will be committed before you run
git commit. - Debugging aid: When something feels wrong,
git statusimmediately shows the state of things. - Orientation: After switching branches, pulling, or merging,
git statustells you where you stand. - Git hints: The output includes helpful commands — "use
git addto track" or "usegit restoreto discard."
Code
# ─── Run git status in different scenarios ───
# Scenario 1: Clean repo (nothing to do)
git status
# Output:
# On branch main
# nothing to commit, working tree clean
# Scenario 2: New file created
echo "TODO" > tasks.md
git status
# Output:
# Untracked files:
# (use "git add <file>..." to track)
# tasks.md
# Scenario 3: File staged
git add tasks.md
git status
# Output:
# Changes to be committed:
# (use "git restore --staged <file>..." to unstage)
# new file: tasks.md
# Scenario 4: Staged + modified (same file, different versions!)
echo "more stuff" >> tasks.md
git status
# Output:
# Changes to be committed:
# new file: tasks.md ← staged version
# Changes not staged for commit:
# modified: tasks.md ← newer working tree changes
# ─── Short format (compact view) ───
git status -s
# Output:
# AM tasks.md
# A = staged, M = modified after staging
# ?? = untracked, M_ = modified+staged, _M = modified onlyReading git status -s (Short Format)
| Symbol | Meaning |
|---|---|
?? | Untracked file |
A | New file, staged |
M | Modified, staged |
M | Modified, NOT staged |
AM | Staged, then modified again |
D | Deleted, staged |
R | Renamed, staged |
Key Takeaways
git statusshows staged, modified, and untracked files in one view.- Run it constantly — before adding, before committing, after pulling.
- The output includes hints — Git tells you what command to run next.
- Use
git status -sfor a compact, scriptable format.
Interview Prep
-
Q: What does
git statusshow you? A: It shows three categories: staged changes (ready to commit), modified but unstaged changes, and untracked files. It also shows the current branch and any merge/rebase state. -
Q: Can the same file appear in both "staged" and "modified" sections? A: Yes. If you stage a file with
git addand then modify it again, the staged version and the newer working tree version are different. The staged version will be committed; the newer changes will not be — unless yougit addagain. -
Q: What does
git status -sshow? A: A compact, two-column format where the first column shows staging area status and the second shows working tree status. For example,AMmeans the file is staged (A) but has been modified again (M) since staging.