Last active
July 8, 2017 02:50
-
-
Save dflima/c5137785c437fcdf0c74a544bfc290fc to your computer and use it in GitHub Desktop.
Deletes branches merged with <branch>
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/bash | |
function usage() | |
{ | |
printf "Usage:\n\n" | |
printf "./delete_merged_branches <branch>\n\n" | |
} | |
if [ "$1" == "" ]; then | |
usage | |
exit 0 | |
fi | |
in_branch="$(git branch | grep \* | cut -d ' ' -f2)" | |
out_branch=$1 | |
git checkout $out_branch; | |
git pull; | |
git branch --merged | grep -v $out_branch | xargs git branch -D; | |
git checkout $in_branch; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@webysther that's a nice feature, but I don't want to delete remote branches. Maybe I can include that as an option. :)