Skip to content

Instantly share code, notes, and snippets.

@shubhamoli
Last active February 4, 2020 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shubhamoli/c88b267bf9b312b0a4cf276394e242f0 to your computer and use it in GitHub Desktop.
Save shubhamoli/c88b267bf9b312b0a4cf276394e242f0 to your computer and use it in GitHub Desktop.
Remove Merged branches in remote
#!/bin/sh
// cut -d '/' -f 2- : this will remove "origin/" from output of first command
//
// I've excluded master, staging and development branches for safety
// But You can change this to suit your use-case
git branch -r --merged | cut -d ‘/’ -f 2- | grep -v ’master\|staging\|development’ | xargs git push --delete origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment