Why?
git revert HEAD makes a new commit that reverses the changes introduced by the last commit.
It does not touch your working directory or index — it just creates a new commit that undoes the previous commit’s changes.
This is the safe way to undo commits on a shared branch, because it preserves history.
Why C (most voted) is wrong
git reset --soft HEAD^ does move the HEAD back by one commit, and it doesn’t change the working tree, but it does change the index — it stages the changes from the reverted commit.
So the index does change, which violates the requirement.
ChatGPT says
A. git revert HEAD
Explanation:
git revert creates a new commit that undoes the changes of a previous commit.
git revert HEAD specifically undoes the last commit without modifying your working directory or index (staging area) — it just adds a new commit that reverses the changes.
This is safe for public/shared branches because it doesn’t rewrite history.
C is correct:
"git reset [<mode>] [<commit>]
This form resets the current branch head to <commit> and possibly updates the index (resetting it to the tree of <commit>) and the working tree depending on <mode>. If <mode> is omitted, defaults to --mixed. The <mode> must be one of the following:
--soft
Does not touch the index file or the working tree at all (but resets the head to <commit>, just like all modes do). This leaves all your changed files "Changes to be committed", as git status would put it."
https://git-scm.com/docs/git-reset
upvoted 4 times
...
This section is not available anymore. Please use the main Exam Page.200-901 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
elgreco1985
2Â weeks, 6Â days agoelgreco1985
2Â weeks, 6Â days agos3eed
8Â months, 1Â week agortg2123
1Â year, 11Â months ago