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