Skip to content

Instantly share code, notes, and snippets.

@wodka
Forked from earlonrails/merged_branches.sh
Last active August 29, 2015 14:05
Show Gist options
  • Save wodka/7df7f3ff9cf9c046528a to your computer and use it in GitHub Desktop.
Save wodka/7df7f3ff9cf9c046528a to your computer and use it in GitHub Desktop.
merged_branches(){
local red=`tput setaf 1`
local green=`tput setaf 2`
local bold=`tput bold`
local reset=`tput sgr0`
local current_branch=$(git rev-parse --abbrev-ref HEAD)
for branch in $(git branch --merged | cut -c3-)
do
if [[ $branch = $current_branch ]]; then
continue
fi
echo "Branch ${bold}$branch${reset} is already merged into ${bold}$current_branch${reset}."
echo "Would you like to delete it? ${green}[Y]es${reset}/${red}[N]o${reset} "
read REPLY
if [[ $REPLY =~ ^[Yy] ]]; 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