Skip to content

Instantly share code, notes, and snippets.

@byF
Last active November 9, 2020 11:32
Show Gist options
  • Save byF/ec41e20986539ab4d5c2ad77e1a881df to your computer and use it in GitHub Desktop.
Save byF/ec41e20986539ab4d5c2ad77e1a881df to your computer and use it in GitHub Desktop.
Put the git-prune-local script on your PATH: git prune-local
#!/bin/sh
. "$(git --exec-path)/git-sh-setup"
USAGE=""
_prune_local() {
if [ $# = 0 ]; then
# git 2.21+
# -D is aggressive, beware
git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D
# more lenient version, depends on your workflow
# git fetch -p && git branch -vv --merged | awk '/: gone]/{print $1}' | xargs git branch -d
else
usage
fi
}
_prune_local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment