Instantly share code, notes, and snippets.

Embed
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) }
}
@refactorsaurusrex

This comment has been minimized.

Owner

refactorsaurusrex 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