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)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git