git delete all branches not on remote code example
Example 1: delete local branches not on remote
git branch -vv | grep ': gone]'| grep -v "\*" | awk '{ print $1; }' | xargs -r git branch -D
Example 2: remove all branches deleted on remote
# set this alias in git.config
git config --global alias.gone "! git fetch -p && git for-each-ref --format '%(refname:short) %(upstream:track)' | awk '\$2 == \"[gone]\" {print \$1}' | xargs -r git branch -D"
# then run
git gone