Files
init-env/home/bin/git-cleanup
T
Andrew Miner 5e0bc94465 Update git-cleanup to be smarter and more informative
* Refresh local state before doing any work
* Only delete branches which have been merged back to master
* List branches deleted and branches remaining
2018-01-31 09:34:45 -07:00

18 lines
307 B
Bash
Executable File

#!/usr/bin/env bash
git checkout master
git pull
DELETED="0"
git branch --merged master | grep -v master | while read BRANCH; do
git branch -d $BRANCH
(( DELETED = DELETED + 1 ))
done
if [[ "$DELETED" -eq "0" ]]; then
echo "No branches to clean up."
fi
echo "Branches remaining:"
git branch