DEV Community

Discussion on: Remove all your local git branches but keep main

Collapse
 
amirhe profile image
Amir.H Ebrahimi

make an alias out of it which also protect master and dev branches,
and also try to delete them in safer way with -d instead of -D.

alias gitrm='git branch --merged | egrep -v "(^\*|master|main|dev)" | xargs git branch -d'
Enter fullscreen mode Exit fullscreen mode