Skip to content

Instantly share code, notes, and snippets.

View TraceyC77's full-sized avatar

Tracey Clark TraceyC77

View GitHub Profile
@TraceyC77
TraceyC77 / git-glean
Created November 15, 2023 22:06 — forked from GrayedFox/git-glean
Remove local branches with a missing (gone) upstream
#!/usr/bin/env bash
# first we prune origin to ensure our local list of remote branches is up to date
git remote prune origin
GONE_BRANCHES=$(git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}')
if [ -z "$GONE_BRANCHES" ]; then
echo "Could not find any local branches that have a gone remote"
exit 0