How can I delete all Git branches which have been merged?

后端 未结 30 1085
离开以前
离开以前 2020-11-22 14:22

I have many Git branches. How do I delete branches which have already been merged? Is there an easy way to delete them all instead of deleting them one by one?

30条回答
  •  长发绾君心
    2020-11-22 15:15

    I use a git-flow esque naming scheme, so this works very safely for me:

    git branch --merged | grep -e "^\s\+\(fix\|feature\)/" | xargs git branch -d
    

    It basically looks for merged commits that start with either string fix/ or feature/.

提交回复
热议问题