Skip to content

Instantly share code, notes, and snippets.

@stoe stoe/git-gone
Last active Mar 23, 2020

Embed
What would you like to do?
delete local branches if they have been deleted remotely
#!/bin/sh
# shellcheck disable=
git fetch -p && for b in $(git for-each-ref --format '%(refname:lstrip=2) %(upstream:track)' refs/heads --no-merged | awk '$2 == "[gone]" {print $1}'); do git branch -D "${b}"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.