Skip to content

Instantly share code, notes, and snippets.

@mvllow
Last active December 18, 2020 23:18
Show Gist options
  • Save mvllow/96bb854884a93f765ad5c92cba71e8c0 to your computer and use it in GitHub Desktop.
Save mvllow/96bb854884a93f765ad5c92cba71e8c0 to your computer and use it in GitHub Desktop.
chop (merged) local branches
git branch --merged | egrep -v "(^\*|master|main)" | xargs git branch -d
@mvllow
Copy link
Author

mvllow commented Sep 30, 2019

Create an alias (~/.zshrc or similar):

alias chop="git branch --merged | egrep -v \"(^\*|master|main)\" | xargs git branch -d"

If you rely heavily on a develop branch for example:

alias chop="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