Last active
September 1, 2022 17:24
-
-
Save gabmontes/6ff956bb844a8a0ad4e92159a23d94fb to your computer and use it in GitHub Desktop.
Prune repo and remove local branches deleted in origin
This file contains 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
#!/bin/bash | |
if [ ! -d .git ]; then | |
echo Not a git repo | |
exit | |
fi | |
if ! (git remote | grep -q origin); then | |
echo No origin remote | |
exit | |
fi | |
git fetch origin | |
git remote prune origin | |
git branch -vv | grep -v -e '*' -e '^\s.master\s.' -e '^\s.develop\s.' -e '^\s.prod\s.' | awk '/: 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