Developing Applications Using Cisco Core Platforms and APIs (DEVCOR) — Question 203

A developer has issued the git add file1 file2 test.py command to add three files for the next commit, but then decides to exclude test.py from this commit. Which command needs to be used to exclude test.py from this commit but keep the rest of the files?

Answer options

Correct answer: D

Explanation

The correct command to unstage a file is 'git reset -- test.py', which removes test.py from the staging area while keeping the other files staged. The other options are incorrect; 'git stash' temporarily saves changes, 'git clean' is used to remove untracked files, and 'git checkout' is for restoring files to a previous state.