Understanding git diff
git diff compares your working tree with the staging area. git diff --staged compares the staged snapshot with the current commit. These commands are essential before committing because they let you verify exactly what will be recorded.
Inspect Changes
git diff
git diff --staged
git diff HEAD
git diff HEAD~1 HEAD💡
git diff shows unstaged changes. git diff --staged shows staged changes. git diff HEAD compares the entire working state against HEAD.Key Takeaways
- Review
git diffbefore staging. - Review
git diff --stagedbefore committing. git diff HEADcombines the comparison against the current commit.
Knowledge Check
Which command shows changes currently staged for commit?