Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jerrymarino/b7b8bfa7a3779ddf4f9662efc1c133f9 to your computer and use it in GitHub Desktop.
Save jerrymarino/b7b8bfa7a3779ddf4f9662efc1c133f9 to your computer and use it in GitHub Desktop.
[Bash 1 liner] Delete all git branches besides the current one
# List all of the current branches - invert * as it represents the current one
# and will cause many issues
for B in $(git branch --list | grep --invert '*'); do git branch -D $B; done
# Additional ideas are cleaning up the remote ( i.e. ):
for B in $(git branch -a --list | grep --invert '*'); do git push origin : $B; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment