XK0-005 · Question #187
XK0-005 Question #187: Real Exam Question with Answer & Explanation
The correct answer is D: git checkout master -- file. When a file on a testing branch has been inadvertently modified and needs to be reverted to its version from the master branch, a specific Git command can be used.
Question
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?
Options
- Agit branch -b master file
- Bgit merge master testing
- Cgit stash branch master
- Dgit checkout master -- file
Explanation
When a file on a testing branch has been inadvertently modified and needs to be reverted to its version from the master branch, a specific Git command can be used.
Common mistakes.
- A.
git branch -b master fileattempts to create a new branch from a file, which is syntactically incorrect and not for reverting files. - B.
git merge master testingwould attempt to integrate changes between the two branches, not revert a single file to a previous state from another branch. - C.
git stash branch mastercreates a new branch from a stash entry, which is unrelated to restoring a file from another existing branch.
Concept tested. Git reverting specific files from another branch
Reference. https://git-scm.com/docs/git-checkout
Topics
Community Discussion
No community discussion yet for this question.