Skip to content
Justice Tech School

Comparing Branches

git diff a..b and git diff --stat compare branches. git log a..b lists commits.

Example
echo one > a.txt && git add a.txt && git commit -qm 'first'
git switch -q -c feat
echo f > f.txt && git add f.txt && git commit -qm 'feat'
git diff --stat main feat | tail -n 1
git diff --name-only main feat

Result

 1 file changed, 1 insertion(+)
f.txt

Exercise

Changed names.

git diff  a b

Quiz Test

What does --stat show?

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