Skip to main content

Repository State Diagnostics

What This Practice Page Is For

This page checks whether you can actually read Git state instead of reacting to command output mechanically.

You should be able to:

  • distinguish working tree, index, and last commit
  • choose between status, diff, diff --staged, log, and show
  • explain repository state in one sentence before acting

Before You Start

Do the first pass from memory in a throwaway repository.

Use this rule:

  • first inspect
  • then explain
  • only then change state

Retrieval Round

Answer from memory:

  1. What is the difference between working tree, index, and repository?
  2. What does git diff compare?
  3. What does git diff --staged compare?
  4. What does HEAD usually point to?
  5. What does git show HEAD tell you that git status does not?

If more than two answers are weak, revisit Cluster 1 before continuing.

Compare and Distinguish

Pair 1

Compare:

  • git status
  • git diff

Explain what each command is for and why one is not a substitute for the other.

Pair 2

Compare:

  • modified
  • staged
  • committed

Give one sentence for each state.

Pair 3

Compare:

  • git log --oneline
  • git show HEAD

Explain when you would prefer each one.

Common Mistake Check

For each mistake:

  1. say what is wrong
  2. write the safer move
  3. explain why

Mistakes:

  1. Committing without checking what is staged.
  2. Using git pull before reading current local state.
  3. Assuming a clean git diff means nothing is staged.
  4. Thinking origin/main updates by itself without communication.

Mini Application

Create this scenario:

  1. one modified tracked file
  2. one staged tracked file
  3. one untracked file

Then run:

git status
git diff
git diff --staged
git log --oneline --decorate --graph --all -3

Write a four-line diagnosis of the repository.

Evidence Check

You are done only when you can:

  • identify what is modified, staged, and untracked
  • choose the right inspection command for each question
  • explain why a command is safe before you use it

If You Got Stuck

Revisit: