Skip to content

Instantly share code, notes, and snippets.

@stoe
Last active March 23, 2020 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stoe/5e0d0dcd09e9a1a360827d9112241df9 to your computer and use it in GitHub Desktop.
Save stoe/5e0d0dcd09e9a1a360827d9112241df9 to your computer and use it in GitHub Desktop.
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