A data scientist has edited three notebooks in a RAPIDS project and run git add on all of them, but has not yet created a commit. Before committing, she wants to see the exact line-level changes that are currently staged for the next commit. Which git command shows only the staged changes?
- ARun git diff with no flags, which compares the working tree against the most recent commit.
- BRun git status, which prints the staged file contents line by line for review.
- CRun git diff with the --staged flag, which compares the staging area against the most recent commit. Correct
- DRun git log with the --patch flag, which prints the staged changes alongside the commit history.
Why A is wrong: Tempting because git diff is the right family of command, but with no flags it compares the working tree against the index and therefore shows only unstaged changes, which is the opposite of what is asked.
Why B is wrong: Tempting because git status does list which files are staged, but it only names the files and their state and never prints line-level content differences, so it cannot show the exact staged changes.
Why C is correct: Correct. git diff --staged (equivalently --cached) compares the index against HEAD, so it shows precisely the changes that have been staged and will go into the next commit.
Why D is wrong: Tempting because git log --patch does show line-level diffs, but it shows diffs for changes that are already committed in history, not changes sitting in the staging area awaiting their first commit.