Git Tricks – Delete local merged branches
It’s all too easy in Git to end up with loads of local branches. Once they have been merged on the remote then they fail to update. Plus, if you run:
$ git branch
It shows you loads of dead branches you will never use again. Like LOADS. If you are using a cool feature like git up then everytime it runs you end up with a huge list of them.
Anyway, enough waffle – solution:
git branch --merged master | grep -v "\master" | xargs -n 1 git branch -d
Add it to bash!
$ vim ~/.bash_profile
Then add the line:
# Add new alias to the bash_profile (git_clean) to call the clean up command alias git_clean="git branch --merged master | grep -v "\master" | xargs -n 1 git branch -d"
Now you can quickly run git_clean to clean all the things!
1 Response
[…] See those error: remote branch doesn't exist? – Clean them up super quickly with one command! […]