Git cleanup: delete local branches deleted on a remote

  1. Prune deleted remotes:

git fetch --prune

2. Identifying “gone” branches and delete them:

git for-each-ref --format '%(refname:short) %(upstream:track)' | awk '$2 == "[gone]" {print $1}' | xargs -r git branch -D

--

--