CS FundamentalsHardCognizant GenC · HCL

A developer checks out a specific commit by its hash and makes two new commits, then switches to main without creating a branch. What is the risk?

  1. A. They are automatically merged into main
  2. B. The two commits become unreachable from any branch and may be garbage collected
  3. C. They are deleted immediately and cannot be recovered even via reflog
  4. D. They are copied to the remote repository

Correct answer: B. The two commits become unreachable from any branch and may be garbage collected

In detached HEAD state commits belong to no branch; once HEAD leaves they are only reachable via reflog until pruned.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic