Skip to content

Instantly share code, notes, and snippets.

@miguelgonz
Created July 1, 2014 10:43
Show Gist options
  • Save miguelgonz/a653e9c6dbd2c06fd5c4 to your computer and use it in GitHub Desktop.
Save miguelgonz/a653e9c6dbd2c06fd5c4 to your computer and use it in GitHub Desktop.
Git-clean-branches
#!/bin/sh
#To make use of this just copy it to your path, +x it, and do git sync
MAIN_BRANCH="develop"
CURRENT_BRANCH=`git symbolic-ref -q --short HEAD`
if [ "$CURRENT_BRANCH" != "$MAIN_BRANCH" ]; then
git checkout $MAIN_BRANCH
fi
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
if [ "$CURRENT_BRANCH" != "$MAIN_BRANCH" ]; then
git checkout $CURRENT_BRANCH
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment