CS FundamentalsVery hardInfosys · Cognizant GenC

Commits A-B-C-D-E are on the shared main branch and already pushed. Commit C introduced a bug. What is the safest way to undo only C's effect?

  1. A. git reset --hard B and force-push
  2. B. git rebase to delete C and force-push
  3. C. git revert C, creating a new commit that reverses C
  4. D. git checkout B and commit there

Correct answer: C. git revert C, creating a new commit that reverses C

Revert adds a new commit that cancels C without rewriting shared history, so D and E remain and collaborators are unaffected.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic