nerdexam
Cisco

200-901 · Question #111

What is the Git command to delete a local branch named "experiment" without a warning?

The correct answer is D. git branch -D experiment. git branch -D force-deletes a local branch immediately and without warning, regardless of whether its commits have been merged.

Software Development and Design

Question

What is the Git command to delete a local branch named "experiment" without a warning?

Options

  • Agit branch -n experiment
  • Bgit branch -rm experiment
  • Cgit branch -f experiment
  • Dgit branch -D experiment

How the community answered

(26 responses)
  • A
    4% (1)
  • C
    8% (2)
  • D
    88% (23)

Why each option

git branch -D force-deletes a local branch immediately and without warning, regardless of whether its commits have been merged.

Agit branch -n experiment

git branch -n is not a valid Git flag for branch deletion; -n has no recognized meaning in the git branch command.

Bgit branch -rm experiment

git branch -rm is not a valid Git command; Git uses -d or -D for branch deletion, not -rm.

Cgit branch -f experiment

git branch -f is the force-reset flag used to move an existing branch pointer to a specific commit, not to delete a branch.

Dgit branch -D experimentCorrect

git branch -D is the force-delete shorthand equivalent to --delete --force, which removes the branch unconditionally without checking whether its changes have been merged into another branch, so no safety warning is issued.

Concept tested: Force deleting a local Git branch without warning

Source: https://git-scm.com/docs/git-branch

Topics

#Git commands#Branch management#Version control

Community Discussion

No community discussion yet for this question.

Full 200-901 Practice