Created
September 15, 2017 20:26
-
-
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
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
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/")}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to get the list only
git branch -r --merged master | %{$_.trim()} | ?{$_ -notmatch 'develop' -and $_ -notmatch 'stage' -and $_ -notmatch 'master'}