Skip to main content

Cleaning up merged git branches

https://spencer.wtf/2026/02/20/cleaning-up-merged-git-branches-a-one-liner-from-the-cias-leaked-dev-docs.html

image.png

I translated this into PowerShell

git branch --merged | Select-String -Pattern "main" -NoMatch | ForEach-Object { git branch -d $_.Line.Trim() }

First part is still the same. Second part leverages Select-String since grep isn't a default Windows tool. xargs is how Linux-based systems iterate over piped contents, so we translate that to ForEach-Object.