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

后端 未结 30 1312
离开以前
离开以前 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 14:59

    Just extending Adam's answer a little bit:

    Add this to your Git configuration by running git config -e --global

    [alias]
        cleanup = "!git branch --merged | grep  -v '\\*\\|master\\|develop' | xargs -n 1 git branch -d"
    

    And then you can delete all the local merged branches doing a simple git cleanup.

提交回复
热议问题