Deleting local git branches after they were squash-merged in GitHub

Our team at uses GitHub’s squash-merge then auto-delete branch functionality a lot.

It’s awesome at a lot of things, but it does cause a bit of a challenge because commands like git fetch --prune don’t work, as the branch wasn’t merged in but was deleted.

The best snippet I’ve found that does this so far:

git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -Df

written on

written by

Discover more from Max Gross

Subscribe to get the latest posts to your email.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.