πŸ” HistoryCommonly used

How to view diffs in Git

See exactly what changed in files, commits or branches.

See unstaged changes
git diff

Shows changes in tracked files that are not yet staged.

See staged changes
git diff --staged

Shows changes that are staged and ready to commit.

When to use: Before committing β€” review exactly what you are about to commit.

Compare two branches
git diff main..feature-branch

Shows all differences between two branches.

Compare two commits
git diff abc1234..def5678

Shows differences between two specific commits.

See only changed file names
git diff --name-only main..feature

Lists only the file names that changed, without the diff content.

← Back to Git Reference