Skip to content

Instantly share code, notes, and snippets.

@matipojo
Last active April 7, 2021 13:20
Show Gist options
  • Select an option

  • Save matipojo/30e485db59d1952c082925297c9bbd10 to your computer and use it in GitHub Desktop.

Select an option

Save matipojo/30e485db59d1952c082925297c9bbd10 to your computer and use it in GitHub Desktop.
# Local
## Dry run, review what will be deleted:
git branch --merged | egrep -v "(^\*|master|develop)"
## Delete!
git branch --merged | egrep -v "(^\*|master|develop)" | xargs git branch -d
# Remote (origin)
## Dry run, review what will be deleted:
git branch -r -l 'origin*' --merged | egrep -v "(^\*|master|develop)" | sed 's/origin\///' |
## Delete!
git branch -r -l 'origin*' --merged | egrep -v "(^\*|master|develop)" | sed 's/origin\///' | xargs -n 1 git push --delete origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment