Last active
May 23, 2022 20:17
-
-
Save legowerewolf/4b907b52a8563fcc0d5a8c58e501b018 to your computer and use it in GitHub Desktop.
Delete all local branches where the corresponding remote tracking branch has been deleted
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
# Requires PowerShell to be installed. Works well when `fetch.prune` is set to `true`. | |
# running from Bash | |
pwsh -c 'git branch -vv | where-object {$_ -like "*: gone]*"} | foreach-object {git branch -D ($_ -split "\s+")[1]}' | |
# running from within pwsh | |
git branch -vv | where-object {$_ -like "*: gone]*"} | foreach-object {git branch -D ($_ -split "\s+")[1]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment