private/Tests/Test-InstallGit.ps1

function Test-InstallGit {
    <#
    .SYNOPSIS
        Returns $true when Git for Windows is installed.
 
    .NOTES
        Author: David Segura
        Company: Recast Software
        Detection: Uninstall registry — DisplayName like 'Git*'.
        Also checks the default install path as a fallback.
    #>

    [OutputType([bool])]
    param ()

    # Fast path — default install location
    if (Test-Path -Path (Join-Path $env:ProgramFiles 'Git\cmd\git.exe')) {
        return $true
    }

    $regPaths = @(
        'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
        'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
    )

    foreach ($regPath in $regPaths) {
        $entry = Get-ItemProperty -Path $regPath -ErrorAction SilentlyContinue |
            Where-Object { $_.PSObject.Properties['DisplayName'] -and $_.DisplayName -like 'Git*' } |
            Select-Object -First 1
        if ($entry) { return $true }
    }

    return $false
}