Last Updated: August 15, 2019
·
1.534K
· robincurry

git branch-cleanup

Do you find yourself staring at a mess when you type git branch. Cleanup after yourself with ease with this git alias.

git branch-cleanup Will delete any local branches that have already been merged as well as prune remote branches that have been deleted from your origin repo.

Add to .gitconfig

...
[alias]
 branch-cleanup = !sh -c 'git branch --merged | grep -v master | xargs git branch -d && git remote prune origin'

1 Response
Add your response

Nice one :) I added this to my cheat sheet. This can be very helpful. (https://github.com/obstschale/gitCS#git-branch-cleanup)

over 1 year ago ·