See what changed
Getting started · Article 2 of 9 · 3 min read
Before you commit, check exactly what you are about to save.
The short version
git status tells you which files changed and which are staged. git diff shows the lines that changed.
Details
git diff compares your working folder with the staging area. Add --staged to compare the staging area with the last commit instead. Reading both before you commit catches stray edits.
Try it yourself
echo "Quack again" >> notes.txt
git status
git diff
git add notes.txt
git diff --staged
The first diff shows the new line. After git add, the plain diff is empty and the staged diff shows the line.
Explain it to the duck
Which diff would you run to review exactly what the next commit will contain?
Tested with: Git 2.51.