Skip to content

Instantly share code, notes, and snippets.

@orez-
Created January 20, 2016 23:01
Show Gist options
  • Save orez-/89bdcb788569673d1b0a to your computer and use it in GitHub Desktop.
Save orez-/89bdcb788569673d1b0a to your computer and use it in GitHub Desktop.
Prune already merged branches.
#!/usr/bin/env bash
branch_name=$(git rev-parse --abbrev-ref HEAD)
if [[ "$branch_name" == "master" ]]; then
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
echo "Done!"
else
echo "Must be on master, not $branch_name!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment