Skip to content

Instantly share code, notes, and snippets.

@jeffpapp
Last active January 8, 2020 17:42
Show Gist options
  • Save jeffpapp/3826fd71f44756401c46 to your computer and use it in GitHub Desktop.
Save jeffpapp/3826fd71f44756401c46 to your computer and use it in GitHub Desktop.
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