Skip to content

Instantly share code, notes, and snippets.

@jasursadikov
Last active September 27, 2023 11:48
Show Gist options
  • Save jasursadikov/af1724ebcfd5ad512459b1510d35c452 to your computer and use it in GitHub Desktop.
Save jasursadikov/af1724ebcfd5ad512459b1510d35c452 to your computer and use it in GitHub Desktop.
Removes all branches that do not exist on remote
#!/bin/bash
git fetch --prune
git branch | grep "feature\/\|bugfix\/" | while read -r p; do
echo "$p"
EXIST=$(git branch -r --contains "$p" | wc -l)
if [[ $EXIST == "0" ]]; then
git branch -D "$p"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment