Skip to content

Instantly share code, notes, and snippets.

@refactorsaurusrex
Last active August 18, 2016 14:31
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 refactorsaurusrex/d120e075c2eaf0e73702 to your computer and use it in GitHub Desktop.
Save refactorsaurusrex/d120e075c2eaf0e73702 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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