CS FundamentalsVery hardGATE CS · TCS NQT Prime · Product Company SDE

What is the safest way to undo the effect of a single bad commit that is already on a shared branch other people have pulled?

  1. A. git revert <commit>, which creates a brand-new commit that reverses the change, without rewriting any existing history
  2. B. Manually editing the remote repository's files on the server
  3. C. Deleting the branch and recreating it from scratch
  4. D. git reset --hard and a force-push to erase the commit

Correct answer: A. git revert <commit>, which creates a brand-new commit that reverses the change, without rewriting any existing history

Revert adds a new commit undoing the change, which is safe for shared history since nothing that collaborators already have gets rewritten or removed.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic