Remove merged branches from a git remote
Bunches of branches cluttering up Github? Here's an easy one-liner to delete branches that are already merged to master:
git branch -r --merged origin/master | grep origin | grep -v master | cut -f2- -d/ | xargs -I% git push origin :%
Bonus! Deleting merged local branches is much the same:
git branch --merged master | grep -v master | xargs -n1 git branch -d
Written by Dean Strelau
Related protips
3 Responses
delete branch on remote
git push origin --delete <branch name>
I believe this does the same thing?
over 1 year ago
·
@arnonate Ah, yes. I believe the --delete
syntax sugar was added in 1.7.0.
over 1 year ago
·
; ) That always annoyed me that I would delete a branch locally, then push to master and they would still be there on the repo... seems like there shouldn't have to be an extra step for that
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Git
Authors
khasinski
591.1K
dmichaelavila
500.4K
Related Tags
#git
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#