Skip to content

Instantly share code, notes, and snippets.

@ayust
Forked from tekkub/gist:1203061
Created September 8, 2011 11:28
Show Gist options
  • Save ayust/1203187 to your computer and use it in GitHub Desktop.
Save ayust/1203187 to your computer and use it in GitHub Desktop.
Git aliases to prune merged branches
[alias]
prunelocal = !sh -c 'git branch --merged | grep -v "^*" | xargs git branch -d'
pruneorigin = prune-remote origin
##################
# Helper aliases #
##################
# prune-remote <remote name>
prune-remote = !sh -c 'git fetch $1 && git remote-master-merged $1 | xargs git push --delete $1' -
# remote-master-merged <remote name>
remote-master-merged = !sh -c 'git remote-merged-refs \"$1\" master' -
# remote-merged-refs <remote name> <destination branch name>
remote-merged-refs = !sh -c 'git branch -r --merged $2 | grep \"^ $1/\" | cut -d/ -f2- | grep -vx $2' -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment