Skip to content

Instantly share code, notes, and snippets.

@stefano-garzarella
Created September 11, 2014 12:57
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save stefano-garzarella/1cd9b2011c27bbdf5241 to your computer and use it in GitHub Desktop.
[GIT] Remove all remote branches except master
#!/bin/bash
#Remove all remote branches except master
REMOTE_NAME="github"
MASTER_BRANCH="master"
git branch -r | grep ${REMOTE_NAME}/ | grep -v ${MASTER_BRANCH} | grep -v HEAD | cut -d/ -f2-10 | while read line; do git push ${REMOTE_NAME} ${MASTER_BRANCH} :$line; done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment