Skip to content

Instantly share code, notes, and snippets.

View d3d-z7n's full-sized avatar

David A. Zimmerman d3d-z7n

View GitHub Profile
@d3d-z7n
d3d-z7n / git-prune-local.zsh
Last active September 16, 2020 19:54
Prompt for and delete local branches that are tracking deleted remote branches
#!/usr/bin/env zsh
# Remove no longer existing remote branches.
git fetch --prune &> /dev/null
# Find all branches with a deleted remote branch.
branches=(${(@f)$(git branch -vv | grep ": gone]" | awk '{ print $1 }')})
if [[ $#branches == 0 ]]; then
print -P "No pruneable local branches found."