nerdexam
CompTIACompTIA

XK0-005 · Question #1182

XK0-005 Question #1182: Real Exam Question with Answer & Explanation

The correct answer is D: git checkout master -- file. To revert a specific file in a testing branch to its version from the master branch, the git checkout master -- <file> command is the best option.

Troubleshooting

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

To revert a specific file in a testing branch to its version from the master branch, the git checkout master -- <file> command is the best option.

Common mistakes.

  • A. git branch -b master file attempts to create a new branch named master from a file, which is not a valid Git operation for reverting a file.
  • B. git merge master testing would attempt to merge changes from the testing branch into the master branch (or merge master into testing if run from testing), which is about combining changes, not selectively reverting a single file.
  • C. git stash branch master creates a new branch and then applies a stashed state to it, which is unrelated to reverting a specific file from another existing branch.

Concept tested. Git checkout specific file from branch

Reference. https://git-scm.com/docs/git-checkout

Topics

#Git#Version Control#Branching#File Management

Community Discussion

No community discussion yet for this question.

Full XK0-005 PracticeBrowse All XK0-005 Questions