Skip to content

Instantly share code, notes, and snippets.

@mitchdenny
Last active October 24, 2021 23:47
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 mitchdenny/72dd41563c8c114addd9ab1a706e9e70 to your computer and use it in GitHub Desktop.
Save mitchdenny/72dd41563c8c114addd9ab1a706e9e70 to your computer and use it in GitHub Desktop.
PowerShell one-liner to clean up all the branches in your local clone except for master. Be careful!
git branch | % { $_.Replace("*", "").Trim() } | where { $_ -ne "main" } | % { git branch -D $_ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment