I thought I was gonna have to build something like this myself but it turns out it’s just there in Git itself!
Ever annoyed by the long list of local Git branches that are no longer relevant? Solution:— Cory House (@housecor) September 21, 2019
git remote prune origin
That removes all local branches that have been deleted from remote (typically GitHub)
Add --dry-run to merely see a list first to confirm.#git