Created
March 19, 2015 21:08
-
-
Save ghinda/0ecebd6cd6a5e51f99be to your computer and use it in GitHub Desktop.
Delete all local tracking git branches for which the origin remote branches have been deleted
This file contains hidden or 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
git for-each-ref --format='%(refname:short)' refs/heads/* | while read branch; do BRANCH_EXISTS=$( git ls-remote --heads origin $branch | wc -l ); if [ $BRANCH_EXISTS -eq 0 ]; then git branch -D $branch; fi;done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment