QA
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→

More Git & GitHub Interview Questions

Beginner LevelGit & GitHub

Compare git rebase versus git merge and explain how git bisect finds regressions.

Beginner LevelGit & GitHub

What is the difference between git init and git clone?

Beginner LevelGit & GitHub

What are the Three Trees in Git (Working Directory, Staging Area / Index, Commit History)?