how to delete a branch using git code example

Example 1: delete local branch

// delete branch locally
git branch -d localBranchName

//delete local branch that is unmerged
git branch -D localBranchName

// delete branch remotely
git push origin --delete remoteBranchName

Example 2: How to Create Branch Delete and View Branch

// View Current Branch status
git status

// List All Branch
git branch

// Create Branch
git branch <branch>

// Delete Branch (safe delete use -D to force delete)
git branch -d <branch>

// Deleting From remote
git push origin --delete crazy-experiment

Rename the current branch to <branch>.
git branch -a

Example 3: git delete branch start with

git branch -d $(git branch | grep yourSearchPattern)

Tags:

Misc Example