Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Git commands: Git Diff: Comparing Repository States

Create a disposable repository with one committed file. Make one change and inspect it with plain `git diff`. Stage that change and inspect it with `git diff --cached`. Edit the file again without staging the second change, then run both commands and explain why they show different content. Finally, run `git diff HEAD` and `git diff HEAD~1 HEAD` after making a second commit, and use `--name-status` with a path restriction to inspect only the file you changed.

Beginner ~6 min read

Challenge 1

Complete the Git command to compare repository states.

bash Your answer
git 

Press Ctrl⌘Enter to check your answer

Challenge 2

Complete the Git command to compare repository states.

bash Your answer
git  --cached

Press Ctrl⌘Enter to check your answer

Challenge 3

Complete the Git command to compare repository states.

bash Your answer
git  HEAD

Press Ctrl⌘Enter to check your answer

Challenge 4

Complete the Git command to compare repository states.

bash Your answer
git  HEAD~1 HEAD

Press Ctrl⌘Enter to check your answer