Skip to content

Instantly share code, notes, and snippets.

@tekkub
Created September 8, 2011 10:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tekkub/1203061 to your computer and use it in GitHub Desktop.
Save tekkub/1203061 to your computer and use it in GitHub Desktop.
Git aliases to prune merged branches
[alias]
prunelocal = !sh -c 'git branch -d `git branch --merged | grep -v "^*" | tr -d "\\n"`'
pruneorigin = !sh -c 'git push origin `git branch -r --merged | grep \"^ origin/\" | grep -v "/master$" | sed "s/origin./:/g" | tr -d "\\n"`'
@ayust
Copy link

ayust commented Sep 8, 2011

@oelmekki
Copy link

oelmekki commented Sep 8, 2011

@ayust
Copy link

ayust commented Sep 8, 2011

@oelmekki - I tend to favor git push --delete over the prefixed colon, mostly because it makes it clearer about what's going on (since git push is not usually mentally associated with destructive actions unless --force is present).

@oelmekki
Copy link

oelmekki commented Sep 8, 2011

@ayust : agreed. I usually don't bother with shell alias coding style, but it's already hard enough to understand what the command does.

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