DEV Community

Ben Collins
Ben Collins

Posted on

3

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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay