git checkout main
git branch -D $(git branch | grep -v 'main') # delete all local but main
git fetch # fetch from origin
git remote prune origin # delete non-existent remote branches
git pull # get to latest on main
git branch --merged master | grep -v '^[ *]*master$' | xargs git branch -d
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d