Skip to content

Instantly share code, notes, and snippets.

@elhoyos
Forked from schacon/gist:942899
Last active October 12, 2015 12:08
Show Gist options
  • Save elhoyos/4024800 to your computer and use it in GitHub Desktop.
Save elhoyos/4024800 to your computer and use it in GitHub Desktop.
Delete all git branches that have been already merged into master
git branch -a --merged master | # merged to master
grep -v '>' | # branch pointers exception
grep -v 'master\|develop' | # exceptions
xargs -L1 | # get the first column
tee >(grep origin |
awk '{split($0,a,"/"); print a[3]}' |
xargs git push origin --delete) | # remove remotes
xargs git branch -d # remove local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment