Last active
September 8, 2021 09:52
-
-
Save lomholdt/c45b24ec036dbd62322623abf9036c66 to your computer and use it in GitHub Desktop.
Remove all git branches besides master and the current in powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Remove-AllGitBranches { | |
,@(git branch | Select-String -Pattern "((\*\s)?master|main)|(\*\s).+" -NotMatch) | ForEach-Object{$_.Line.Trim()} | ForEach-Object{git branch -D $_} | |
} |
Updated to include main
branch.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a Powershell command to delete all git branches besides the master and the one you are currently on.