Created
March 9, 2017 15:53
-
-
Save marcpeabody/60d621157385e1ef98fca7ba67414ed5 to your computer and use it in GitHub Desktop.
git branch deletion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function git_bd { # git local branch deletion | |
# deletes any local feature branches no longer needed | |
# branches without a remote are kept | |
# branches with unpushed changes are kept | |
git checkout master | |
for bra in `git branch | awk '/([0-9].*)/ {print $1}'` | |
do | |
set -A o `git branch -r | grep $bra` | |
if [ "$o" != "" ] | |
then | |
set -A diff "`git cherry -v $o $bra`" | |
if [ "$diff" != "" ] | |
then | |
echo $bra has unpushed changes. not deleting | |
else | |
git branch -D $bra | |
fi | |
else | |
echo $bra did not have an origin of the same name | |
fi | |
done | |
git branch | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment