Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jonathanconway/2ec5e4da1c02eb91014b9605d68576d5 to your computer and use it in GitHub Desktop.

Select an option

Save jonathanconway/2ec5e4da1c02eb91014b9605d68576d5 to your computer and use it in GitHub Desktop.
Bash script: Delete all branches except `main` in the current git repo
# 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