DEV Community

Ben Collins
Ben Collins

Posted on

Deleting remote-pruned branches in Git with PowerShell

It's easy to wind up with a substantial collection of branches that aren't on the remote anymore that keep Git's gc from cleaning up as much as it should. Let's get rid of them.

git branch -vv | sls gone `
  |% { $_.ToString().Trim() -split '\s+' | select -first 1 } `
  |% { git branch -D $_ }

Top comments (0)