Intermediate LevelGit & GitHub
What is the difference between git diff and git diff --staged?
❓ Interview Prompt: Compare git diff (Working Directory vs Staging Index) versus git diff --staged (Staging Index vs HEAD commit).
git diff compares Working Directory edits against the Staging Area Index. git diff --staged compares staged changes in the Index against the last HEAD commit.
Code Implementation Example
bash
git diff
git diff --staged💡Inspecting unstaged edits vs staged edits using git diff.
🎯 Interview Key Takeaway
Use git diff to inspect unstaged working edits, and git diff --staged to inspect staged changes ready for commit.
#git diff#git diff --staged#Intermediate
Back to all Git & GitHub Questions→