Created
June 9, 2022 08:21
-
-
Save namuan/b7123b8d07ccb99d89a0e2032ddec518 to your computer and use it in GitHub Desktop.
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
function git_delete_missing_remote_branches() { | |
bold=$(tput bold) | |
normal=$(tput sgr0) | |
git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'); do echo -n "Delete this branch ${bold}$branch${normal}? [y/n] " && read should_delete && (test "$should_delete" = 'y' && git branch -D $branch || echo "Ignoring branch $branch"); done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment