Skip to content

Instantly share code, notes, and snippets.

@peterpme
Created July 30, 2020 04:09
Show Gist options
  • Save peterpme/7cf8be2dc44d3da809e061111875d1f3 to your computer and use it in GitHub Desktop.
Save peterpme/7cf8be2dc44d3da809e061111875d1f3 to your computer and use it in GitHub Desktop.
Interactive git branch delete
# fbd - delete git branch (including remote branches)
fbd() {
local branches branch
branches=$(git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format="%(refname:short)") &&
branch=$(echo "$branches" | fzf --multi ) &&
git branch -D $(echo "$branch" | sed "s/.* //" | sed "s#remotes/[^/]*/##")
}
## place this in your ~/.zshrc and make sure you have fzf installed: brew install fzf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment