Skip to main content

Sign in

Save your progress and access it from any device.

Or with email

Don't have an account?

Privacy policy

Git diff: compare your changes

git diff shows you exactly what has changed in your files, line by line. Essential for reviewing your work before committing.

The different modes of git diff

git diff

Unstaged changes (working dir vs staging)

git diff --staged

Staged changes (staging vs last commit)

git diff HEAD

All changes (working dir vs last commit)

git diff a..b

Differences between two branches or commits

Git diff in practice

Reading unstaged and staged changes.

Unstaged diff

Staged diff and summary

Reading git diff output

diff --git a/file b/file

Header: which file is being compared

--- a/file / +++ b/file

a/ = old version, b/ = new version

@@ -5,7 +5,8 @@

Position in the file: line 5, 7 lines before / 8 lines after

- removed line
+ added line

Lines without a prefix are unchanged context

Part of the Git Basics guide

A

GitQuest is created by Anaïs (nouvelle fenêtre), web developer and head of education, specializing in tech training and digital accessibility.

Questions about git diff

Learn to read diffs in GitQuest

Investigations ask you to analyze changes to solve problems.

Start practicing now