Recall & Review
beginner
What does the command
git diff --staged show?It shows the differences between the files in the staging area and the last commit. In other words, it displays what changes are ready to be committed.
Click to reveal answer
beginner
How is
git diff --staged different from git diff?git diff shows changes in your working directory that are not yet staged, while git diff --staged shows changes that have been staged and are ready to commit.Click to reveal answer
beginner
Can
git diff --staged be used to see changes after committing?No. It only shows staged changes that are not yet committed. After committing, the staging area is cleared, so no staged changes remain.
Click to reveal answer
beginner
What is the purpose of staging changes in Git?
Staging lets you prepare and review changes before committing them. It acts like a 'ready to commit' basket where you collect changes you want to include in the next commit.
Click to reveal answer
beginner
How do you stage a file for commit in Git?
Use
git add <filename> to move changes from your working directory to the staging area.Click to reveal answer
What does
git diff --staged compare?✗ Incorrect
git diff --staged shows differences between the staged files and the last commit.
Which command shows changes not yet staged?
✗ Incorrect
git diff shows changes in the working directory that are not staged.
What must you do before
git diff --staged shows any output?✗ Incorrect
You need to stage changes first using git add for git diff --staged to show differences.
If you run
git diff --staged and see no output, what does it mean?✗ Incorrect
No output means there are no changes staged for commit.
Which command stages a file named
app.js?✗ Incorrect
git add app.js stages the file app.js for commit.
Explain what
git diff --staged does and when you would use it.Think about the staging area and what is ready to be saved in Git.
You got /3 concepts.
Describe the difference between
git diff and git diff --staged.Consider where the changes are: working directory or staging area.
You got /2 concepts.