Software Engineering · Question 13 · Hard

What happens after running git reset --soft HEAD~1?

  1. The last commit is removed and its changes are discarded from the working directory
  2. The last commit is undone and its changes remain staged in the index
  3. The last commit is undone and its changes stay in the working directory but are unstaged
  4. A new commit is created that reverses the last commit
Answer and explanation

Answer: B. The last commit is undone and its changes remain staged in the index

Explanation: --soft moves the branch pointer back one commit but leaves the index and working tree alone, so the changes stay staged. --mixed (the default) unstages them, --hard discards them, and git revert creates an inverse commit.

Previous: A function accepts an integer age that is valid from 18 to 60. Using… · Next: When does git perform a fast-forward merge of branch feature into main?

Practise software engineering

Try a fresh set of software engineering questions with an explanation after every answer, free and without signing up: Software Engineering practice. Or sit a full placement mock test.

More software engineering questions

More technical & programming practice

Cloud & DevOps · GenAI Basics · Pseudo-code · C Programming · Java · Python · Data Structures · Algorithms

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge