Created
October 10, 2014 20:59
-
-
Save cblage/dafc1286a50221f4e745 to your computer and use it in GitHub Desktop.
Git Prune Branches
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 gitPruneBranches() { | |
local remote="$1" | |
local delete_arg="$2" | |
if [ -z "$remote" ]; then | |
echo "must define a remote" | |
return 1 | |
fi | |
if [ -z "$delete_arg" ]; then | |
delete_arg="-d" | |
fi | |
echo "Pruning branches for remote=${remote}" | |
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep "${remote}") | awk '{print $1}' | xargs git branch "${delete_arg}" | |
} | |
alias gpb='gitPruneBranches' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment