Skip to content

Instantly share code, notes, and snippets.

@Vladis466
Created April 6, 2022 13:52
Show Gist options
  • Save Vladis466/31806bd053db5c1981884a0835149220 to your computer and use it in GitHub Desktop.
Save Vladis466/31806bd053db5c1981884a0835149220 to your computer and use it in GitHub Desktop.
Here’s a script that deletes branches that used to exist on the remote but no longer do
git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'); do git branch -D $branch; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment