Last active
April 2, 2025 16:11
-
-
Save eneko/ebaf7e04eb898391afff5371c70887d1 to your computer and use it in GitHub Desktop.
`git purge` command to delete local branches that have been deleted on remote
This file contains hidden or 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
#!/usr/bin/env sh | |
set -e | |
echo "Pulling latest code..." | |
git pull | |
echo "Deleting local branches that were removed in remote..." | |
git fetch -p | |
git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D | |
echo "Remaining local branches:" | |
git branch -vv | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice, many thanks!