CS FundamentalsVery hardProduct-company placement · Git

On main, git revert HEAD~3..HEAD is run with no conflicts. What happens?

  1. A. The four commits HEAD~3 to HEAD are reverted, oldest first, in one commit
  2. B. HEAD~2, HEAD~1 and HEAD are reverted, newest first, one commit each
  3. C. Only HEAD~3 is reverted, because the range names that commit first
  4. D. The branch is reset to HEAD~3 and the three later commits are deleted

Correct answer: B. HEAD~2, HEAD~1 and HEAD are reverted, newest first, one commit each

A..B excludes A, so the range is the three commits after HEAD~3. git revert undoes them newest first, which avoids conflicts between dependent changes, adding a new commit for each; nothing is removed from history.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic