Skip to content

Instantly share code, notes, and snippets.

@naftulikay
Created September 30, 2016 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naftulikay/67fcd2e48abb9de00fb7595137438fcc to your computer and use it in GitHub Desktop.
Save naftulikay/67fcd2e48abb9de00fb7595137438fcc to your computer and use it in GitHub Desktop.
Usage: `git branch-clean`
#!/bin/bash
# Usage: git branch-clean
#
# Removes all branches which have been successfully merged safely.
# Uses -d instead of -D to ensure only merged branches will be
# deleted.
#
# Install this script on your PATH somewhere.
set -ex
git branch --merged | egrep -v "(^\*|master|dev|production)" | \
xargs -r git branch -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment