CS FundamentalsHardProduct-company placement · Git interview

You run git branch -d experiment and Git refuses: 'the branch is not fully merged'. You force it with git branch -D. Which statement is correct?

  1. A. The branch's commits are deleted from disk immediately
  2. B. The commits disappear from the remote too
  3. C. The branch label is removed; its commits become unreachable but can still be recovered via the reflog until garbage collection prunes them
  4. D. -D merges the branch into main before deleting it

Correct answer: C. The branch label is removed; its commits become unreachable but can still be recovered via the reflog until garbage collection prunes them

A branch is just a pointer. Deleting it leaves the commits in the object store; the reflog (or git fsck) can find their hash for a new branch until they expire and are garbage-collected.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic