Diff
In one line
A diff shows the exact lines that were added, removed, or changed between two versions of your files.
In simple words
git diff shows the differences between two states of your repository. Lines prefixed with - were removed; lines prefixed with + were added. The diff format also shows file names and line numbers for context.
Common uses: git diff (unstaged changes), git diff --staged (staged changes), git diff <branch1> <branch2> (differences between branches), and git diff <commit1> <commit2> (differences between two commits).
Diffs are essential for code review — they show exactly what a commit or pull request changes. Reading diffs is a core developer skill. The output can be large, so tools like git diff --stat (show only file names and change counts) or visual diff tools are helpful.
Example
# See unstaged changes
git diff
# See staged changes
git diff --staged
# Compare two branches
git diff main feature
# Summary of changes
git diff --statdiff shows line-by-line changes. - means removed, + means added.
Related terms
Related Resources
Related Lessons
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.