Skip to content

Instantly share code, notes, and snippets.

@andrx
Created September 15, 2017 20:26
Show Gist options
  • Save andrx/ec290c7923a68337aa10fe96864690e9 to your computer and use it in GitHub Desktop.
Save andrx/ec290c7923a68337aa10fe96864690e9 to your computer and use it in GitHub Desktop.
git. Remove all remote branches merged into 'master' using powershell without checking them out
git branch -r --merged master | %{$_.trim()} | ?{$_ -notmatch 'develop' -and $_ -notmatch 'stage' -and $_ -notmatch 'master'} | %{git branch -d -r $_; if($?){ git push origin $_.Replace("origin/",":refs/heads/")}}
@andrx
Copy link
Author

andrx commented Mar 20, 2020

to get the list only git branch -r --merged master | %{$_.trim()} | ?{$_ -notmatch 'develop' -and $_ -notmatch 'stage' -and $_ -notmatch 'master'}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment