git delete 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: git delete local branch
git branch -d test
Example 3: git delete local branch
$ git push -d <remote_name> <branch_name>
$ git branch -d <branch_name>
Example 4: git delete local branch
$ git for-each-ref --format '%(refname:short) %(upstream:track)' |
awk '$2 == "[gone]" {print $1}' |
xargs -r git branch -D
Deleted branch fix-typo (was 7b57d4f).
Deleted branch grammar-fix (was 01257bd).
Example 5: git delete local branch
[alias]
gone = ! "git fetch -p && git for-each-ref --format '%(refname:short) %(upstream:track)' | awk '$2 == \"[gone]\" {print $1}' | xargs -r git branch -D"
Example 6: git delete local branch
git branch | grep "branch*" | xargs git branch -D