Skip to content

Instantly share code, notes, and snippets.

@candeira
Created January 22, 2015 01:23
Show Gist options
  • Save candeira/a87cf0b5a71b20543662 to your computer and use it in GitHub Desktop.
Save candeira/a87cf0b5a71b20543662 to your computer and use it in GitHub Desktop.
git deadbranches command deletes all local and remote branches merged into develop
#!/usr/bin/env bash
git checkout develop || (echo "Aborting..." && exit 1)
git pull || (echo "Aborting..." && exit 1)
BRANCHES=$(git branch --merged | grep -v develop | grep -v master | tr -d "\n")
for BRANCH in $BRANCHES
do
git branch -d $BRANCH && git push --delete origin $BRANCH
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment