Skip to content

Instantly share code, notes, and snippets.

@bjorg
Created April 9, 2013 22:03
Show Gist options
  • Select an option

  • Save bjorg/5349825 to your computer and use it in GitHub Desktop.

Select an option

Save bjorg/5349825 to your computer and use it in GitHub Desktop.
Script to delete all *remote* branches that have been merged into the local master branch. Useful after updating the local master branch and removing the remote branches that have been merged into master.
#!/bin/sh
git remote prune origin
git branch -r --merged origin/master | awk -F'/' '/^ *origin/{if(!match($0, /(>|master)/)){print $2}}' | xargs git push origin --delete
git remote prune origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment