Skip to content

Instantly share code, notes, and snippets.

@Tzrlk
Last active January 28, 2016 03:07
Show Gist options
  • Save Tzrlk/988c255b15110f613db4 to your computer and use it in GitHub Desktop.
Save Tzrlk/988c255b15110f613db4 to your computer and use it in GitHub Desktop.
Simple scripts to purge merged branches from your git server.
#!/bin/sh
echo "Switching to $1."
git symbolic-ref HEAD refs/heads/$1
echo "Removing all merged branches."
git branch --merged | grep -i '$2' | xargs -n 1 git branch -d
echo "Switching back to master."
git symbolic-ref HEAD refs/heads/master
#!/bin/sh
echo "Purging all branches not matching '$1'"
git branch | grep -ni '$1' | xargs -i -n 1 git purge {} $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment