Skip to content

Instantly share code, notes, and snippets.

@kellymclaughlin
Created March 1, 2013 15:55
Show Gist options
  • Save kellymclaughlin/5065549 to your computer and use it in GitHub Desktop.
Save kellymclaughlin/5065549 to your computer and use it in GitHub Desktop.
#!/bin/sh
oIFS=$IFS
IFS="
"
ROOTDIR=`pwd`
if [ "$1" = "-p" ]; then
PRINT=1
else
PRINT=0
fi
for repo in `find . -name .git -type d | xargs -n1 dirname`; do
echo ""
echo "Repo: $repo"
cd $repo
# for branch in `git branch -r --merged origin/master`; do
for branch in `git branch`; do
# branchname=`echo $branch | awk -F"/" '{ print $2 }'`
branchname=`echo $branch | awk '{ gsub(/ */, "", $1); print $1 }'`
if [ "$PRINT" -eq 1 ]; then
echo "Unmerged branch $branchname"
elif [ "$branchname" = "master" ]; then
echo "Ignoring master branch"
elif [ "$branchname" = "1.0" ]; then
echo "Ignoring 1.0 release branch"
elif [ "$branchname" = "0.0" ]; then
echo "Ignoring 0.0 release branch"
elif [ "$branchname" = "0.1" ]; then
echo "Ignoring 0.1 release branch"
else
read -s -n 1 -p "Delete fully merged branch $branchname? [y/N]" ANS
if [ "$ANS" = "y" ]; then
echo ""
# git push origin :$branchname
git branch -D $branchname
else
echo ""
fi
fi
done
cd $ROOTDIR
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment