Skip to content

Instantly share code, notes, and snippets.

@lukeorland
Last active August 23, 2022 02:47
Show Gist options
  • Save lukeorland/a23327a2c206b07384fbcf24e0eb3a18 to your computer and use it in GitHub Desktop.
Save lukeorland/a23327a2c206b07384fbcf24e0eb3a18 to your computer and use it in GitHub Desktop.
#! /usr/bin/env zsh
# https://stackoverflow.com/questions/7726949/remove-tracking-branches-no-longer-on-remote/38404202#comment91928557_38404202
function git-prune-not-fully-merged-branches {
git fetch
git checkout main
git branch -vv | grep ': gone]'| grep -v "\*" | awk '{ print $1; }' | xargs -r git branch -d
git checkout -
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment