0
0
Gitdevops~20 mins

git diff for working directory changes - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Diff Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2: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 diff
AShows the line differences between the last committed version and the current modified file.
BShows the differences between the staged changes and the last commit.
CShows no output because changes are not staged.
DShows the commit history of the file.
Attempts:
2 left
💡 Hint
Think about what git diff compares by default when no options are given.
🧠 Conceptual
intermediate
2: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?
Agit diff --cached
Bgit diff --staged
CBoth B and C
Dgit diff
Attempts:
2 left
💡 Hint
There are two equivalent options to show staged changes.
Troubleshoot
advanced
2: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?
AYou have no changes in the working directory.
BThe file was staged already, so changes are not in working directory.
CThe file is ignored by Git.
DYou ran <code>git diff</code> in a different directory.
Attempts:
2 left
💡 Hint
Think about what git diff compares by default.
🔀 Workflow
advanced
2: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.
A2, 1, 3
B1, 2, 3
C3, 2, 1
D2, 3, 1
Attempts:
2 left
💡 Hint
First see unstaged changes, then stage, then see staged changes.
Best Practice
expert
2: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?
Agit diff
Bgit diff --name-only
Cgit diff HEAD
Dgit status
Attempts:
2 left
💡 Hint
Think about which command summarizes all changes and untracked files.