701-100 Exam QuestionsBrowse all questions from this exam

701-100 Exam - Question 8


The file index.php, which is being maintained in a git repository, was changed locally and contains an error. If the error has not been committed to the repository yet, which of the following git commands reverts the local copy of index.php to the latest committed version in the current branch?

Show Answer
Correct Answer: C

To revert the local copy of a file to the latest committed version in the current branch, the appropriate command is 'git checkout -- filename'. In this case, 'git checkout -- index.php' will restore 'index.php' to the state of the latest commit, thus removing any uncommitted changes.

Discussion

4 comments
Sign in to comment
Blob21Option: C
Jun 21, 2021

C seems correct. See https://www.arubacloud.com/tutorial/installation-and-first-steps-with-git.aspx

hythaloOption: C
Nov 8, 2020

I agree with mutan. Correct answer is C. git revert only reverts already existing commits. https://git-scm.com/docs/git-revert/2.22.0#_description

Asong01
Dec 18, 2020

I disagree with mutan and hythalo. Git checkout is used when you want to create a new branch or switch to another branch. By checking out will not affect any changes made in the file. git reset would have been the right answer, but it's not on the list. The closest answer to git reset is git revert. So option B is the CORRECT ANSWER.

[Removed]
Mar 2, 2022

git-checkout - Switch branches or restore working tree files

mutanOption: C
Sep 28, 2020

Isn't the correct answer C? git revert only undos already commited changes.

jchavarria12Option: D
Aug 4, 2021

git reset is for undoing uncommitted changes, but it isn't an option, next option will be git clean: https://www.atlassian.com/git/tutorials/undoing-changes https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting