Software Engineering · Question 25 · Medium

Software Engineering question 25

A bad commit has already been pushed to a shared main branch that teammates have pulled. Which command safely undoes its effect without rewriting history?

  1. git revert <commit>
  2. git reset --hard <commit>~1 followed by git push --force
  3. git commit --amend
  4. git checkout <commit>
Answer and explanation

Answer: A. git revert <commit>

Explanation: git revert creates a new commit that applies the inverse changes, so the existing history stays intact for everyone. Resetting and force-pushing rewrites shared history and disrupts teammates.

Previous: You have uncommitted changes but must switch branches quickly to fix an urgent… · Next: A Scrum team completed 30, 34 and 26 story points in its last three sprints…

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