Skip to content

Instantly share code, notes, and snippets.

View Excalibaard's full-sized avatar

Bart Sluis Excalibaard

View GitHub Profile
@GrayedFox
GrayedFox / git-glean
Last active October 22, 2024 02:23
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