DEV Community

Discussion on: Command Line Snippets do you keep handy?

Collapse
 
skkeeper profile image
Fábio André Damas

Inspired by yours but adapted for my use case: delete all branches that are already merged into the current branch safely (doesn't delete branches that aren't fully merged and shows warning):

git branch --merged | grep -v "$(git rev-parse --abbrev-ref HEAD)" | xargs git branch -d 

I use this on develop to delete old feature and bugfix branches.