Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save onmotion/512ab8a898fc714270609ade8c9266b3 to your computer and use it in GitHub Desktop.
Save onmotion/512ab8a898fc714270609ade8c9266b3 to your computer and use it in GitHub Desktop.
git remove all branches except master
#!/bin/bash
# local
git branch | grep -v "master" | xargs git branch -D
# remote
git branch -a --merged remotes/origin/master | grep -v master | grep "remotes/origin/" | cut -d "/" -f 3- | 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