Skip to content

Instantly share code, notes, and snippets.

@ozydingo
Created March 4, 2022 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozydingo/12a5b3882d64c39ad83713a96e7ca996 to your computer and use it in GitHub Desktop.
Save ozydingo/12a5b3882d64c39ad83713a96e7ca996 to your computer and use it in GitHub Desktop.
Delete local git branches that were deleted from remote
git fetch -p
git branch -vv | \
awk '$3 ~ /\[[[:punct:][:alnum:]]+:/ && $4 == "gone]" { print $1}' | \
while read branch; do echo git branch -D $branch; git branch -D $branch; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment