Diff Variants
git diff compares working tree and index. --staged compares index and last commit. Two refs compare commits. --stat and --name-only summarise.
Example
echo one > a.txt && git add a.txt && git commit -qm 'first'
echo two >> a.txt
git diff --stat | tail -1
git add a.txt
git diff --staged --name-only
git diff --staged | grep '^+two'Result
1 file changed, 1 insertion(+) a.txt +two
Exercise
See staged changes.
git diff Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.