Chris Straw
SHARE:

Delete [Prune] Local Merged Branches

Example 1

git branch --merged | egrep -v "master|develop" | xargs git branch -d

Example 2

git branch --merged | egrep -v "master|develop|main|staging" | xargs git branch -d

Example 3
Remove ALL local branches that are not on remote

git fetch -p && git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -d