user3687895
user3687895

Reputation: 163

How to delete a local branch in git?

I want to delete a local branch in Git but this failed:

git branch -d <branch_name>

Upvotes: 1

Views: 1214

Answers (4)

irvnriir
irvnriir

Reputation: 826

for more info . hidden deep from online documentation:

  • -d is a shortcut for --delete , and
  • -D is for --delete --force .

Upvotes: 2

Jo&#235;l Salamin
Jo&#235;l Salamin

Reputation: 3576

Your command to delete a branch is correct:

git branch -d <branch_name>

But you may have an error message indicating you need to use the -D option to force the deletion of the branch:

git branch -D <branch_name>

Upvotes: 1

Zubair
Zubair

Reputation: 6233

git branch -D <branch_name>

Upvotes: 1

mahbub_siddique
mahbub_siddique

Reputation: 1795

If you edit your branch & want to delete it without merging it to your master branch, you have to force delete it with the option -D instead of -d.

git branch -D <branch_name>

Upvotes: 11

Related Questions