exam questions

Exam 200-901 All Questions

View all questions & answers for the 200-901 exam

Exam 200-901 topic 1 question 362 discussion

Actual exam question from Cisco's 200-901
Question #: 362
Topic #: 1
[All 200-901 Questions]

Which command reverses the last commit without changing the index file or the working tree position?

  • A. git revert HEAD
  • B. git reset --hard HEAD~3
  • C. git reset --soft HEAD^
  • D. git revert
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
elgreco1985
2 weeks, 6 days ago
Selected Answer: A
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.
upvoted 1 times
...
elgreco1985
2 weeks, 6 days ago
Selected Answer: A
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.
upvoted 1 times
...
s3eed
8 months, 1 week ago
Selected Answer: C
correct
upvoted 1 times
...
rtg2123
1 year, 11 months ago
Selected Answer: C
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
...
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.

SaveCancel
Loading ...