Skip to content

Instantly share code, notes, and snippets.

@jantimon
Created December 27, 2016 08:36
Show Gist options
  • Save jantimon/5b9fd9330f38d076a374c03fcbb788e1 to your computer and use it in GitHub Desktop.
Save jantimon/5b9fd9330f38d076a374c03fcbb788e1 to your computer and use it in GitHub Desktop.
[alias]
# Delete any branches that have been merged except master, development and the current branch
cleanup = !git remote prune origin && git branch --merged | egrep -v '(^\\*|master|develop)' | xargs git branch -d
@duanasq
Copy link

duanasq commented Jan 4, 2021

thx! updated it a tiny bit. comment is a great idea.

 # Prune remote branches and delete any local branches that have been merged except master, development and the current branch
  # Run it in the main branch
  cleanup-branches = !git remote prune origin && git branch --merged | egrep -v '(^\\*|master|main|develop)' | xargs git branch -d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment