nerdexam
CompTIACompTIA

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.

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

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 file attempts to create a new branch from a file, which is syntactically incorrect and not for reverting files.
  • B. git merge master testing would attempt to integrate changes between the two branches, not revert a single file to a previous state from another branch.
  • C. git stash branch master creates 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

#Git#Version Control#File Reversion#Git Commands

Community Discussion

No community discussion yet for this question.

Full XK0-005 PracticeBrowse All XK0-005 Questions