Skip to content
Justice Tech School

Viewing Changes with diff

git diff shows unstaged changes. git diff --staged shows what will be committed.

Example
echo one > a.txt && git add a.txt && git commit -qm 'first'
echo two >> a.txt
git diff | grep '^[+-]' | grep -v '^+++\|^---'
git add a.txt
git diff --staged --stat | tail -1

Result

+two
 1 file changed, 1 insertion(+)

Exercise

Staged changes.

git diff 

Quiz Test

What does plain git diff compare?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.