Skip to content

Instantly share code, notes, and snippets.

@nyctef
Created December 4, 2017 12:51
Show Gist options
  • Save nyctef/d7f24872ff896f2947067477b9b9e003 to your computer and use it in GitHub Desktop.
Save nyctef/d7f24872ff896f2947067477b9b9e003 to your computer and use it in GitHub Desktop.
delete branches with confirmation
function confirm($message) {
$reply = Read-Host -Prompt "$message [y/n]"
return $reply -match "[yY]"
}
git for-each-ref --format='%(refname:short)' refs/heads | `
where { $_ -ne 'master' } | `
where { confirm "Delete branch $_ ?" } | `
foreach { echo "git branch -D $_" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment