delete local 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: git delete branches that aren't on remote
git fetch --all --prune
Example 3: git delete remote branches in local git
git fetch --all --prune
Example 4: git delete local branches not on remote
git fetch -p && for branch in $(git branch -vv | grep ': gone]' | awk '{print $1}'); do git branch -D $branch; done