git diff is your window into what has changed in your repository. This tutorial explains how to compare staged vs unstaged changes, diff between branches and commits, and how to read the unified diff format.
The Problem
You've made changes across several files but you can't remember exactly what you modified. You're about to commit but you want to double-check the diff first — and you're not sure which `git diff` command to run.
git diff is your window into change. Reviewing the diff before staging or committing is one of the best habits you can build: it catches accidental changes, debug code left in, and missing files before they enter your history.
Common mistakes developers make with this:
Running `git diff` after staging and seeing nothing, because the diff of staged changes requires `--staged`
Not reviewing the diff before committing and pushing unwanted changes
Misreading the unified diff format (red = removed, green = added)
Forgetting you can diff between any two commits or branches
Gitoryx: Gitoryx shows a live side-by-side diff panel as you select files or commits in the UI — no commands needed.
What is Diff: See What Changed Before You Commit?
`git diff` compares two snapshots of your code and shows what changed. By default it compares your working directory to the staging area. Add `--staged` to compare staged changes to the last commit.
Step-by-Step Guide
1
See unstaged changes (working directory vs index)
Running `git diff` with no arguments shows all changes that are not yet staged.
`git diff` compares the working directory to the staging area. Once you've staged your changes with `git add`, the working directory and index are in sync. Use `git diff --staged` to see staged changes.
How do I compare two branches with git diff?
Run `git diff <branch1> <branch2>`. For example `git diff main feature/login` shows what would change if you merged the feature branch into main.
How do I see only the names of changed files?
Use `git diff --name-only`. Add `--name-status` to also see whether each file was Added (A), Modified (M), or Deleted (D).
What does the `@@` line in a diff mean?
The `@@ -a,b +c,d @@` header shows the line range of the hunk. `-a,b` means starting at line `a` for `b` lines in the old file; `+c,d` is the same for the new file.
Everything in this tutorial is faster and clearer with a visual Git client. Gitoryx is free, runs natively on macOS, Windows, and Linux, and built for developers who want to move fast without breaking things.