33 lines
789 B
Plaintext
Executable File
33 lines
789 B
Plaintext
Executable File
# ! /usr/bin/env bash
|
|
#
|
|
# Adapted from http://devblog.springest.com/a-script-to-remove-old-git-branches
|
|
#
|
|
|
|
# This has to be run from master
|
|
git checkout master
|
|
|
|
# Update our list of remotes
|
|
git fetch
|
|
git remote prune origin
|
|
|
|
# # Remove local fully merged branches
|
|
# git branch --merged master | grep -v 'master$' | xargs git branch -d
|
|
|
|
# Show remote fully merged branches
|
|
echo "The following remote branches are fully merged and will be removed:"
|
|
git branch -r --merged master | sed 's/ *origin\///' | grep '^topic/'
|
|
|
|
if [ $? != 0 ]; then
|
|
exit 0
|
|
fi
|
|
|
|
read -p "Continue (y/n)? "
|
|
|
|
if [ "$REPLY" == "y" ]
|
|
then
|
|
# Remove remote fully merged branches
|
|
git branch -r --merged master | sed 's/ *origin\///' \
|
|
| grep '^topic/' | xargs -I% git push origin :%
|
|
echo "Done!"
|
|
fi
|