Skip to content

Instantly share code, notes, and snippets.

@lucaspiller
Created January 15, 2016 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lucaspiller/c0678861c6c5925ed4e9 to your computer and use it in GitHub Desktop.
Save lucaspiller/c0678861c6c5925ed4e9 to your computer and use it in GitHub Desktop.
#!/bin/sh
# This has to be run from develop
git checkout develop
# Update our list of remotes
git fetch
git remote prune origin
# Remove local fully merged branches
git branch --merged develop | grep -v 'develop$' | xargs git branch -d
# Show remote fully merged branches
echo "The following remote branches are fully merged and will be removed:"
git branch -r --merged develop | sed 's/ *origin\///' | grep -v 'develop$'
read -p "Continue (y/n)? "
if [ "$REPLY" == "y" ]
then
# Remove remote fully merged branches
git branch -r --merged develop | sed 's/ *origin\///' \
| grep -v 'develop$' | xargs -I% git push origin :%
echo "Done!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment