Skip to content

Instantly share code, notes, and snippets.

@dflima
Last active July 8, 2017 02:50
Show Gist options
  • Save dflima/c5137785c437fcdf0c74a544bfc290fc to your computer and use it in GitHub Desktop.
Save dflima/c5137785c437fcdf0c74a544bfc290fc to your computer and use it in GitHub Desktop.
Deletes branches merged with <branch>
#!/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;
@dflima
Copy link
Author

dflima commented Nov 4, 2016

@webysther that's a nice feature, but I don't want to delete remote branches. Maybe I can include that as an option. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment