[Git] Delete Merged Branch
Delete Merged Branch
# list local branches that were merged in remote
git branch --merged
# skipping branches containg master|main|dev
# for example branch name like devlop will be excluded
git branch --merged | egrep -v "(^\*|master|main|dev)"
# count number of branches
git branch --merged | egrep -v "(^\*|master|main|dev)" | wc -l
# delete the following branches (excluding branches containing the name master|main|dev)
git branch --merged | egrep -v "(^\*|master|main|dev)" | xargs git branch -d