git delete all local branch code example
Example 1: git delete local branch
// delete branch locally
git branch -d localBranchName
// delete branch remotely
git push origin --delete remoteBranchName
Example 2: delete all local branches git
$ git branch | grep -v "master" | xargs git branch -D
Example 3: git delete all branches except master
git branch | grep -v "master" | xargs git branch -D
Example 4: git branch delete all local branches
// hard delete
git branch -D $(git branch)
Example 5: git delete all local branches
git for-each-ref --format '%(refname:short)' refs/heads | grep -v master | xargs git branch -D