How to Delete Local and Remote Git Branches code example

Example 1: delete local branch git

git branch -d <branch_name>

Example 2: how to delete a branch git

// delete branch locally
git branch -d localBranchName

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

Example 3: git delete remote branches in local git

# Fetch changes from all remotes and locally delete 
# remote deleted branches/tags etc
# --prune will do the job :-;
git fetch --all --prune

Example 4: How to Delete Local/Remote Git Branches

$ git branch -r | egrep -v -f /dev/fd/0  <(git branch -vv | grep origin) | xargs git branch -d

Example 5: How to Delete Local/Remote Git Branches

$ git branch -a

# *master
# b1
# remote/origin/master
# remote/origin/b1

$ git push origin --delete b1
# [...]
# - [deleted] b1