Challenge - 5 Problems
Git Diff Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of
git diff after modifying a tracked file?You have a file
app.txt tracked by Git. You change a line in this file but do not stage it. What does git diff show?Git
git diffAttempts:
2 left
💡 Hint
Think about what
git diff compares by default when no options are given.✗ Incorrect
git diff by default shows changes in the working directory compared to the index (staging area). Since the file is modified but not staged, it shows the differences between the index and the current file.
🧠 Conceptual
intermediate2:00remaining
Which command shows differences between staged changes and the last commit?
You have modified and staged some files. You want to see what changes are staged compared to the last commit. Which command do you use?
Attempts:
2 left
💡 Hint
There are two equivalent options to show staged changes.
✗ Incorrect
git diff --staged and git diff --cached both show differences between the index (staged files) and the last commit.
❓ Troubleshoot
advanced2:00remaining
Why does
git diff show no output after modifying a file?You edited a tracked file but running
git diff shows no output. What could be the reason?Attempts:
2 left
💡 Hint
Think about what
git diff compares by default.✗ Incorrect
If the file is staged, git diff shows differences between working directory and index. If no changes exist in working directory (because changes are staged), it shows nothing.
🔀 Workflow
advanced2:00remaining
What is the correct sequence to view unstaged changes, stage them, and then view staged changes?
Arrange these commands in the correct order to see unstaged changes, stage them, and then see staged changes.
Attempts:
2 left
💡 Hint
First see unstaged changes, then stage, then see staged changes.
✗ Incorrect
First, git diff shows unstaged changes. Then git add stages them. Finally, git diff --staged shows staged changes.
✅ Best Practice
expert2:00remaining
Which command safely shows all changes including untracked files before committing?
You want to review all changes including unstaged, staged, and untracked files before committing. Which command shows this best?
Attempts:
2 left
💡 Hint
Think about which command summarizes all changes and untracked files.
✗ Incorrect
git status shows staged, unstaged changes and untracked files in a clear summary, helping review before commit.