Last active
March 18, 2024 19:25
-
-
Save shanerk/a300b9f5e5f49de9f2570616350eb1f1 to your computer and use it in GitHub Desktop.
Cleanup deleted branches (PowerShell)
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
# Step 1: git fetch -p | |
git fetch -p | |
# Step 2: git for-each-ref --format '%(refname:short) %(upstream:track)' | awk '$2 == "[gone]" {print $1}' | xargs git branch -D | |
git for-each-ref --format '%(refname:short) %(upstream:track)' | Where-Object { $_.Split(' ')[1] -eq '[gone]' } | ForEach-Object { git branch -D $_.Split(' ')[0] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment