Last active
June 22, 2022 03:10
-
-
Save williamluisan/d931594562017fba4eb012dac3099b42 to your computer and use it in GitHub Desktop.
git prune local branch
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
(unix-like) | |
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d | |
(linux) | |
git branch --merged | egrep -v "(^\*|master|main|dev)" | xargs git branch -d | |
(windows) | |
git branch --merged | Select-String -Pattern "develop" -NotMatch | ForEach-Object {git push origin --delete "$_".Trim(); git branch -d "$_".Trim()} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment