At work we are using topic branches which are integrated into a few (3) master branches at some point. Now I\'d like to delete all topic branches from my remote reposit
For a Windows box I use this PowerShell oneliner to clean all merged remote git branches on a weekly basis using Windows Scheduled Tasks on our build system:
git branch --all --merged remotes/origin/master | Select-String -NotMatch "master" | Select-String -NotMatch "HEAD" | Select-String "remotes/origin/" | Foreach-Object { $_.ToString().Replace("remotes/origin/", "").Trim() } | Foreach-Object { git.exe push origin --delete $_ }
Remark: it combines most of the answers already given but without capping the number of branch cleans.