by n4r9 · 2y ago · 0 comments
git-delete-gone-branches
?EDIT: I saw your other comment (incorrectly) claiming that git remote prune origin will do the job. I don't know of any git trickery that can do the job. And believe me I'd love it if there was something.
https://stackoverflow.com/questions/7726949/remove-tracking-...
git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -dThe script in OP handles that edge case by switching to the main branch before deleting. That may or may not be intuitive but I think it's a reasonable response. The script also prints error messages for various other bad inputs. Once you strip all that out it's only a few lines long.