Delete all local git branches except main Jun 26, 2021 git for-each-ref --format '%(refname:short)' refs/heads | grep -v main | xargs git branch -D