Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JohnRDOrazio/c57a8739bf26e1801385c35321d9db81 to your computer and use it in GitHub Desktop.
Save JohnRDOrazio/c57a8739bf26e1801385c35321d9db81 to your computer and use it in GitHub Desktop.
remove local git branches that are no longer on remote - one liner bash
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