Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Delete all local git branches
function Delete-LocalBranches ($Commit = 'HEAD', [switch]$Force) {
git branch |
? { $_ -notmatch '(^\*)|(^. master$)' } |
% { git branch $(if($Force) { '-D' } else { "-d" }) $_.Substring(2) }

This comment has been minimized.

Copy link
Owner Author

commented Jun 28, 2016

Call Delete-LocalBranches -F to delete all branches, regardless of whether they've been merged with master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.