Beginner lesson 3 of 6

Read Git status, diffs, and commit history

Identify staged, unstaged, and untracked changes and inspect the exact snapshot that a commit records.

Before you start

You are preparing a commit with one staged edit, another unstaged edit, and a new untracked file. Learn which command answers each question before you include anything.

Use Git 2.28 or newer in a POSIX shell on macOS/Linux, or Git Bash on Windows. Check git --version; Git's installation page covers setup. Each example starts in a new temporary folder. Keep that folder if you want to revisit your work; none of these commands removes your existing projects. The identity and signing settings below apply only to the practice repository.

Work through the example

practice=$(mktemp -d "${TMPDIR:-/tmp}/gitglow-learn.XXXXXX")
sandbox="$practice/project"
mkdir "$sandbox"
cd "$sandbox"
git init -b main
git config --local user.name "Git Learner"
git config --local user.email "learner@example.invalid"
git config --local commit.gpgsign false
printf 'A small project\n' > notes.txt
git add notes.txt
git commit -m "Start notes"
printf 'Reviewed addition\n' >> notes.txt
git add notes.txt
printf 'Still deciding\n' >> notes.txt
printf 'Private draft\n' > draft.txt
git status --short
git diff -- notes.txt
git diff --cached -- notes.txt
git log --oneline
git show HEAD:notes.txt

Check the result

Status shows MM notes.txt (staged and unstaged modifications) and ?? draft.txt (untracked). Plain git diff shows Still deciding; the cached diff shows Reviewed addition. Neither diff lists the contents of draft.txt, so inspect it with cat draft.txt. git show HEAD:notes.txt shows only the original committed line.

Try it yourself

Unstage notes.txt with git restore --staged notes.txt, then rerun both diffs. The cached diff should be empty and the working diff should contain both added lines. The file contents remain intact.

If something goes wrong

An empty working diff can mean everything is staged or already committed. Check the cached diff and history before concluding there are no changes. Short status columns refer to index first, working tree second; conflict codes need separate inspection.

Use this workflow in GitGlow

Use Changes for pending files and select a file to inspect its diff. Use History for committed changes, and revision comparisons when reviewing a branch whose work is already committed. These everyday read and diff workflows are Free.

Download GitGlow Free

Go deeper with the official Git docs

These references cover command options and behavior beyond this example.