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

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

    If you're on Windows you can use Windows Powershell or Powershell 7 with Out-GridView to have a nice list of branches and select with mouse which one you want to delete:

    git branch --format "%(refname:short)" --merged  | Out-GridView -PassThru | % { git branch -d $_ }
    

    after clicking OK Powershell will pass this branches names to git branch -d command and delete them

提交回复
热议问题