Lesson Completion
Back to course

git status

Beginner
8 minutes4.8Git

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:

QuestionSection in OutputWhat 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:

  1. Untracked → Git doesn't know this file exists
  2. Tracked, unmodified → Git knows it, nothing changed (doesn't appear in status)
  3. Tracked, modified → You changed it, but haven't staged the changes
  4. Staged → Changes are selected for the next commit
  5. 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

flowchart TD GS["🔍 git status"] --> Q1{"Any staged<br/>changes?"} Q1 -->|Yes| S1["✅ Changes to be committed"] Q1 -->|No| Q2{"Any modified<br/>files?"} Q2 -->|Yes| S2["⚠️ Changes not staged"] Q2 -->|No| Q3{"Any untracked<br/>files?"} Q3 -->|Yes| S3["❓ Untracked files"] Q3 -->|No| S4["✨ Working tree clean"] style GS fill:#0f3460,stroke:#53d8fb,color:#53d8fb style S1 fill:#1b2d1b,stroke:#53d8fb,color:#53d8fb style S2 fill:#2d2d1b,stroke:#ffd700,color:#ffd700 style S3 fill:#2d1b1b,stroke:#e94560,color:#e94560 style S4 fill:#1b2d1b,stroke:#53d8fb,color:#53d8fb

Why It Matters

  • Prevents accidents: See exactly what will be committed before you run git commit.
  • Debugging aid: When something feels wrong, git status immediately shows the state of things.
  • Orientation: After switching branches, pulling, or merging, git status tells you where you stand.
  • Git hints: The output includes helpful commands — "use git add to track" or "use git restore to discard."

Code

bash
# ─── 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 only

Reading git status -s (Short Format)

SymbolMeaning
??Untracked file
A New file, staged
M Modified, staged
MModified, NOT staged
AMStaged, then modified again
D Deleted, staged
R Renamed, staged

Key Takeaways

  • git status shows 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 -s for a compact, scriptable format.

Interview Prep

  • Q: What does git status show 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 add and 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 you git add again.

  • Q: What does git status -s show? A: A compact, two-column format where the first column shows staging area status and the second shows working tree status. For example, AM means the file is staged (A) but has been modified again (M) since staging.

Topics Covered

Git BasicsGit Fundamentals

Tags

#git#status#workflow#beginner-friendly

Last Updated

2026-02-12