Created
September 10, 2018 21:20
-
-
Save alexanderbez/ea35747b626f1aa646803bf4a5f056bb to your computer and use it in GitHub Desktop.
A shell function to purge all local git branches that do not exist on remote.
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
func purgeLocalGitBranches() { | |
red='\033[0;31m' | |
echo "${red}Purging local branches no longer found on remote..." | |
git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment