Created
July 21, 2025 10:30
-
-
Save rakshithxaloori/e80fa13e05c65d5aaa83274a85e9a86e to your computer and use it in GitHub Desktop.
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
# 1. nuke every *local* branch ≠ main | |
git branch | grep -vE '^\*? ?main$' | xargs -r git branch -D | |
# 2. tell your repo to forget any stale remote tracking refs | |
git fetch --prune origin | |
# 3. nuke every *remote* branch ≠ main | |
git branch -r | grep -vE 'origin/(HEAD|main)$' \ | |
| sed 's|origin/||' \ | |
| xargs -r -I{} git push origin --delete {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment