Public/Get-MainBranch.ps1

1
2
3
4
5
6
7
8
9
<#
    .SYNOPSIS
        Returns the name of the main branch (i.e. usually either master or main).
#>

function Get-MainBranch() {
    $remoteBranch = Invoke-NativeCommand git rev-parse --abbrev-ref origin/HEAD
    $remoteBranch.Substring('origin/'.Length)
}