Last active
March 23, 2020 11:00
-
-
Save stoe/5e0d0dcd09e9a1a360827d9112241df9 to your computer and use it in GitHub Desktop.
delete local branches if they have been deleted remotely
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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