Skip to content

Instantly share code, notes, and snippets.

@mattkaye
Created August 14, 2023 16:15
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 mattkaye/5a48b8161403d56e444149eac4ea643c to your computer and use it in GitHub Desktop.
Save mattkaye/5a48b8161403d56e444149eac4ea643c to your computer and use it in GitHub Desktop.
Prune all git branches not on remote
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