Skip to content

Instantly share code, notes, and snippets.

@thnk2wn
Created May 12, 2019 01:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thnk2wn/30f8fd689a61efab6d4f5f45b03e1358 to your computer and use it in GitHub Desktop.
Save thnk2wn/30f8fd689a61efab6d4f5f45b03e1358 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment