CS FundamentalsHardAccenture · Git interview

Branches deleted on the remote still appear in git branch -r on a developer's machine. Which command removes these stale remote-tracking branches?

  1. A. git branch -D origin/*
  2. B. git fetch --prune
  3. C. git reset --hard origin
  4. D. git clean -fd

Correct answer: B. git fetch --prune

Remote-tracking refs are only updated by fetch; --prune also deletes the ones whose remote branch no longer exists. Local branches are unaffected.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic