Delete Git Branch

The git branch -d command is used to delete a local branch.

Syntax

git branch -d <branch-name>

Example: git branch -d user_signin_feature

In some cases, deleting of a branch may failed if the branch contains commits that have not been merged with any local or remote branch. If you want to delete such a branch forcefully then use -D flag.

Syntax:

git branch -D <branch-name>

Example: git branch -D user_signin_feature

Delete a Remote Git branch

After deleting a local branch, you may want to delete the remote branch as well. To delete a remote branch, you need to first delete it locally and then push the update as follows:

Syntax

git push -d origin <branch-name>

Example: git push -d origin user_signin_feature