NCA-ADS - Software and Environment Management (6% of the exam) - Section 8.4
Use version control with git.
Use git to version notebooks, scripts, and configuration files, committing incremental changes to preserve a reproducible project history. Apply branching strategies to isolate experimental work from stable baselines and avoid overwriting validated results.
git
Practice question for this objective
lock_openFree sampleSoftware and Environment Managementeasy
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.check_circle Correct
DRun git log with the --patch flag, which prints the staged changes alongside the commit history.
Use git diff --staged to inspect the exact line-level changes held in the staging area before committing. The staging area (index) sits between the working tree and committed history. git diff --staged compares the index to HEAD, so it isolates exactly what a new commit would record, whereas plain git diff compares the working tree to the index and shows only unstaged edits.
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.
Answers that look right on this material and are not. Each one is a distractor from a different question in the NCA-ADS bank for this domain.
Run git clone in the directory, which converts the existing local folder into a tracked repository.
errorWhy it is wrong: Tempting because cloning produces a working repository, but git clone copies an existing remote or local repository into a new location; it does not initialise tracking for a folder that has no upstream source.
Delete the files before each commit and restore them afterwards
errorWhy it is wrong: Deleting and restoring files manually is error-prone and does not prevent accidental staging; the files could easily be committed before deletion, exposing secrets or bloating history
Run git status, which prints each historical commit on the branch together with its message and hash.
errorWhy it is wrong: Tempting because git status reports on the current branch, but it only describes the present working tree and staging state; it never lists historical commits or their identifiers.