Skip to content

Instantly share code, notes, and snippets.

@jeffpapp
Last active January 8, 2020 17:42
Embed
What would you like to do?
Clean Git Merged Branches Powershell
# Remove remote branches that don't exist anymore
git remote prune origin
# List branches, find ones where the origin is gone, then delete each branch name
git branch -vv | Select-String -Pattern "origin/.*: gone]" | ForEach-Object{($_ -split "\s+")[1]} | %{git branch -D $_}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment