Skip to content

Instantly share code, notes, and snippets.

@aarontam
Last active February 26, 2016 19:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aarontam/560aed7e0ecef79c7550 to your computer and use it in GitHub Desktop.
Save aarontam/560aed7e0ecef79c7550 to your computer and use it in GitHub Desktop.
Remove local branches that have already been merged.
# Excludes master, by default; other branches can be added with an additional pipe i.e. | grep -v dev
# Update "[branch_to_check_against]" to be the branch where the to-be-pruned branches have been merged into (by default, this is master)
# Adapted from http://stackoverflow.com/a/18143078/1569595
git pull && git branch --merged [branch_to_check_against] | grep -v "\*" | grep -v master | grep -v [branch_to_check_against] | xargs -n 1 git branch -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment