Skip to content

Instantly share code, notes, and snippets.

@DavidMCarek
Created June 1, 2021 13:56
Show Gist options
  • Save DavidMCarek/d17e46742873cb1992c60b61a71ddb0e to your computer and use it in GitHub Desktop.
Save DavidMCarek/d17e46742873cb1992c60b61a71ddb0e to your computer and use it in GitHub Desktop.
Cleanup local git branches that have been deleted on remote using powershell.
git fetch -p | Write-Host
git branch -vv | where {$_ -match '\[origin/.*: gone\]'} | foreach {git branch -D ($_.split(" ", [StringSplitOptions]'RemoveEmptyEntries')[0])} | Write-Host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment