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

后端 未结 30 1055
离开以前
离开以前 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:23

    Alias version of Adam's updated answer:

    [alias]
        branch-cleanup = "!git branch --merged | egrep -v \"(^\\*|master|dev)\" | xargs git branch -d #"
    

    Also, see this answer for handy tips on escaping complex aliases.

提交回复
热议问题