Skip to content

Commit

Permalink
Merge pull request #199 from tlvince/refactor/git-delete-merged-branches
Browse files Browse the repository at this point in the history
Simplify delete-merged-branches
  • Loading branch information
tj committed Nov 19, 2013
2 parents 9760f52 + a909c8d commit 0faaec7
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions bin/git-delete-merged-branches
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
#!/bin/sh

delete_all="no"
current_branch=`git rev-parse --symbolic-full-name --abbrev-ref HEAD`

test "$1" = "-f" -o "$1" = "--force" && delete_all="yes"

git for-each-ref --shell --format="branch=%(refname:short)" refs/heads | \
while read entry
do
eval "$entry"
merged=`git rev-list -n 1 $branch --not HEAD | wc -l`
if [ "$merged" = "0" -a "$branch" != "master" -a "$branch" != "$current_branch" ]; then
if [ "$delete_all" = "no" ]; then
read -p "Delete merged branch $branch? [y/n/a] " yna < /dev/tty
test "$yna" = "a" && delete_all="yes"
fi
test "$yna" = "y" -o "$delete_all" = "yes" && git branch -D $branch
fi
done
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d

0 comments on commit 0faaec7

Please sign in to comment.