CHAPTER 6 : Review Staged or Unstaged File
Since we already know that git status helps us get info about operations, it can be a bit too descriptive.
If you want a more concise view of what changes you actually made, use:
git diff shows changes made to files that are not staged yet. It highlights lines added (green) and removed (red).
git diff --staged shows differences between the last commit and staged changes, which will be part of the next commit.
๐ฆ Git Workflow Visual
Understand where each command fits in the Git staging process:
Working Directory โโ[git add]โโโถ Staging Area โโ[git commit]โโโถ Repository
โฒ โฒ
โ โ
[git diff] [git diff --staged]
๐ Real-Life Example
Imagine you're working on main.css and app.js:
# Make changes to both files
echo "body { color: red; }" >> main.css
echo "console.log('Update');" >> app.js
# Stage main.css only
git add main.css
# Run diffs
git diff # See changes in app.js (unstaged)
git diff --staged # See staged changes in main.css
๐งช Git Diff Visualizer
Select files and see what git diff and git diff --staged would show:
No files selected yet.
๐ง Quick Quiz
Q: You staged file1.txt but not file2.py. Which command shows changes in file2.py?