Skip to content

Instantly share code, notes, and snippets.

@jinqian
Created November 19, 2019 09:34
Show Gist options
  • Save jinqian/bcd1aa082e6875ed608fa6b00525d3fe to your computer and use it in GitHub Desktop.
Save jinqian/bcd1aa082e6875ed608fa6b00525d3fe to your computer and use it in GitHub Desktop.
Delete branch by pattern

To delete many branches based on a specified pattern do the following:

  • Open the terminal, or equivalent.
  • Type in git branch | grep "<pattern>" for a preview of the branches that will be deleted.
  • Type in git branch | grep "<pattern>" | xargs git branch -D

Replace the with a regular expression to match your branch names and that’s it.

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