Created
February 23, 2026 06:04
-
-
Save arjshiv/6d18c3dd58726d18ec190ba38758cc05 to your computer and use it in GitHub Desktop.
checkout main/master and delete old branches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git checkout master && git pull origin && git remote prune origin && git gc && git for-each-ref --format='%(refname:short)|%(upstream:track)' refs/heads | awk -F'|' '$2 ~ /\[gone\]/ {print $1}' | while read -r b; do [ -n "$b" ] && [ "$b" != "master" ] && git branch -D "$b" 2>/dev/null || true; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment