Last Updated: August 24, 2016
·
1.073K
· cristurm

GIT - Delete all local branches that have been merged

Just saving it for future reference.

This deletes all local branches that have been merged already:

git branch --merged | grep -v \* | xargs git branch -d

--merged : gets only merged branches

grep -v * : kicks master branch out of the list

1 Response
Add your response

It'd probably be better to use -d instead of -D to ensure that only the merged branches are caught. It shouldn't make a difference either way, but -d adds that little bit of insurance to this operation.

over 1 year ago ·