Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save yetanotherchris/88de0d4a33804971235a5b5eb82badec to your computer and use it in GitHub Desktop.

Select an option

Save yetanotherchris/88de0d4a33804971235a5b5eb82badec to your computer and use it in GitHub Desktop.
Powershell functions - clean Git branches, recursive search
#notepad $PROFILE
function Clean-GitBranches()
{
git fetch --prune
git branch -vv | Select-String "\[gone\]" | % { git branch -D (($_ -split "\s+")[1]) }
git branch | % { $_.Trim() } | ? { $_ -ne "main" -and $_ -ne "master" -and -not (git branch -vv $_ | Select-String "\[origin/") } | % { git branch -D $_ }
}
function searchRecurse($query, $extension = "*")
{
Write-Host "Searching for '$query' with extension '$extension'"
Get-ChildItem -Path . -Recurse -Filter $extension | Where-Object { $_.Name -like "*$query*" }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment