Created
July 25, 2026 11:13
-
-
Save yetanotherchris/88de0d4a33804971235a5b5eb82badec to your computer and use it in GitHub Desktop.
Powershell functions - clean Git branches, recursive search
This file contains hidden or 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
| #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