CS FundamentalsModerateWipro NLTH · Cognizant GenC

After committing by mistake, a developer runs git reset --soft HEAD~1. What is the result?

  1. A. The last commit is removed and its changes are left unstaged in the working tree
  2. B. The last commit is removed from history but its changes stay staged
  3. C. The last commit and all of its changes are discarded
  4. D. A new commit that reverses the last commit is created

Correct answer: B. The last commit is removed from history but its changes stay staged

--soft moves the branch pointer back only; index and working tree are untouched. --mixed would unstage, --hard would discard, and revert makes a new commit.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic