git diff

See exactly what changed in your files, line by line

What it does

git diff shows the difference line by line: removed lines are marked -, added ones +. With no arguments it compares the files in your folder with the index, which means the edits you have not staged with git add yet.

With --staged (also --cached) it compares the index with the last commit: exactly what the next commit will contain. Handy to check before git commit. Name a file to see just that file, or two commits to compare them.

Syntax

git diff
git diff <file>
git diff --staged
git diff <commit> <commit>

Examples

Related commands

Practise · All commands