Skip to content

Instantly share code, notes, and snippets.

@gmoraleda
Last active May 27, 2024 11:28
Show Gist options
  • Save gmoraleda/faf48f6c374b7d29adf2e917fb9d0867 to your computer and use it in GitHub Desktop.
Save gmoraleda/faf48f6c374b7d29adf2e917fb9d0867 to your computer and use it in GitHub Desktop.
git purge
#!/usr/bin/env sh
set -e
echo "⬇️ Pulling latest code..."
git pull --quiet
echo "🔥 Deleting local branches that were removed in remote..."
git fetch -p
git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D
echo "🌳 Remaining local branches:"
echo "-------------------------"
git --no-pager branch -vv
echo "-------------------------"
echo "✅ Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment