Created
May 14, 2026 23:13
-
-
Save jonathanconway/2ec5e4da1c02eb91014b9605d68576d5 to your computer and use it in GitHub Desktop.
Bash script: Delete all branches except `main` in the current git repo
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
| # Generated by AI. | |
| # Prompt: Write a bash command that switches git to `main` branch and removes all git branches except `main`. | |
| git checkout main && git branch | grep -v '^\* main$' | grep -v '^ main$' | xargs -r git branch -D |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment