Skip to content

Instantly share code, notes, and snippets.

@nibble-4bits
Last active January 23, 2022 00:30
Show Gist options
  • Save nibble-4bits/596abda664cfc69f37482faec3c7d2eb to your computer and use it in GitHub Desktop.
Save nibble-4bits/596abda664cfc69f37482faec3c7d2eb to your computer and use it in GitHub Desktop.
A bash script to delete all branches merged to the branch passed as first argument
#!/bin/bash
# Delete gone remote branches
git remote prune origin
# List all local branches that were published to the remote and delete them
git branch -v | awk -e '/gone/ { print $1 }' | xargs git branch -D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment