CompTIA Linux+ (XK0-004) — Question 284

An issue was discovered on a testing branch of a Git repository. A file was inadvertently modified and needs to be reverted to the master branch version. Which of the following is the BEST option to resolve the issue?

Answer options

Correct answer: D

Explanation

The correct answer is D because 'git checkout master -- file' allows you to restore the specific file from the master branch to the current working directory. Option A is incorrect because 'git branch -b' is not a valid command. Option B is not suitable as merging does not revert the file to the master version. Option C doesn't apply here since 'git stash' is used for saving changes temporarily, not for reverting files.