Skip to content

Instantly share code, notes, and snippets.

@jschaul
Created April 7, 2014 15:02
Show Gist options
  • Save jschaul/10022023 to your computer and use it in GitHub Desktop.
Save jschaul/10022023 to your computer and use it in GitHub Desktop.
delete git feature branches that are no longer needed since they have been merged.
#assumes that there is a "develop" branch
git checkout develop
echo "the following branches have been merged into the develop branch."
echo "By proceeeding they will be purged from your local machine and from the remote:"
git branch --merged | grep -v "\*" | grep -v "master" | grep -v "develop" | xargs -n 1
while true; do
read -p "Do you want to proceed? (y/n): " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) echo "* You canceled; "; exit;;
* ) echo "| Please type (Y/N): ";;
esac
done
git branch --merged | grep -v "\*" | grep -v "master" | grep -v "develop" | xargs -n 1 git push --delete origin
git branch --merged | grep -v "\*" | grep -v "master" | grep -v "develop" | xargs -n 1 git branch -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment