Find all branches that reference a given change or commit message or hash param -> number of commits back to check param -> Folder to work in parma -> target to search for git branch | % { $branchName = $_.Trim(); if (!!(git log $branchName -n 5 --compact-summary | Select-String Headless)) { $branchName } }