Skip to content

Instantly share code, notes, and snippets.

@leoapost
Created December 17, 2012 13:55
Show Gist options
  • Save leoapost/4318441 to your computer and use it in GitHub Desktop.
Save leoapost/4318441 to your computer and use it in GitHub Desktop.
Delete all remote branches, except master
# Replace REMOTE_NAME with your remote name (e.g. origin)
git branch -r | grep REMOTE_NAME/ | grep -v 'master$' | grep -v HEAD| cut -d/ -f2 | while read line; do git push REMOTE_NAME :$line; done;
@vinayf
Copy link

vinayf commented Feb 21, 2019

Sweeeeet, thanks for sharing!

@VishwasShashidhar
Copy link

This is great! Thank you for sharing!

@mohshannan
Copy link

Thanks for sharing

@marnee01
Copy link

Thanks to the OP and others who added additional info. Very helpful!

@jmsalcido
Copy link

thanks

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