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.
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)- A4% (1)
- C8% (2)
- D88% (23)
Why each option
git branch -D force-deletes a local branch immediately and without warning, regardless of whether its commits have been merged.
git branch -n is not a valid Git flag for branch deletion; -n has no recognized meaning in the git branch command.
git branch -rm is not a valid Git command; Git uses -d or -D for branch deletion, not -rm.
git branch -f is the force-reset flag used to move an existing branch pointer to a specific commit, not to delete a branch.
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
Community Discussion
No community discussion yet for this question.