Last active
August 18, 2016 14:31
-
-
Save refactorsaurusrex/d120e075c2eaf0e73702 to your computer and use it in GitHub Desktop.
Delete all local git branches
This file contains 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 Delete-LocalBranches ($Commit = 'HEAD', [switch]$Force) { | |
git branch | | |
? { $_ -notmatch '(^\*)|(^. master$)' } | | |
% { git branch $(if($Force) { '-D' } else { "-d" }) $_.Substring(2) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Call
Delete-LocalBranches -F
to delete all branches, regardless of whether they've been merged with master.