Windows清除除当前分支外的所有本地分支
PowerShell
git branch | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne "" -and $_ -ne $null -and $_ -notmatch '^\*' } | ForEach-Object { git branch -D $_ }
命令行提示符
for /f "tokens=*" %i in ('git branch ^| findstr /v /c:"*"') do git branch -D %i
Git Bash
git branch | grep -v "$(git symbolic-ref --short HEAD)" | xargs git branch -D
