Last active
May 15, 2020 12:26
-
-
Save thnk2wn/840b1d478092a10b6b8aecb9993e12b1 to your computer and use it in GitHub Desktop.
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
function Remove-MergedBranches | |
{ | |
Get-ChildItem -Recurse -Depth 2 -Force | | |
Where-Object { $_.Mode -match "h" -and $_.FullName -like "*\.git" } | | |
ForEach-Object { | |
$dir = Get-Item (Join-Path $_.FullName "../") | |
pushd $dir | |
"removing merged branches in $($dir.Name)" | |
git branch --merged | %{$_.trim()} | ?{$_ -notmatch 'develop' -and $_ -notmatch 'master'} | %{git branch -d $_} | |
popd | |
} | |
} | |
Remove-MergedBranches | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment