Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benbrandt22/20163774fa5e33593b24d38e3d6da502 to your computer and use it in GitHub Desktop.
Save benbrandt22/20163774fa5e33593b24d38e3d6da502 to your computer and use it in GitHub Desktop.
PowerShell command to delete all branches except main
git checkout main; git branch -D @(git branch | select-string -NotMatch "main" | Foreach {$_.Line.Trim()})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment