Skip to content

Instantly share code, notes, and snippets.

@andrx
Last active April 4, 2022 14:26
Show Gist options
  • Save andrx/6ee89c9a69deb1b0151848140a061eed to your computer and use it in GitHub Desktop.
Save andrx/6ee89c9a69deb1b0151848140a061eed to your computer and use it in GitHub Desktop.
git. Remove all remote branches except 'master' and 'develop' on powershell without checking them out
git branch -a | %{$_.trim()} | ?{$_ -notmatch 'develop' -and $_ -notmatch 'master'} | %{$_.Replace("remotes/","")} | %{git branch -d -r $_ ; if($?){ git push origin $_.Replace("origin/",":refs/heads/")}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment