Get the name of the current git branch with PowerShell Get the name of the current git branch with PowerShell powershell powershell

Get the name of the current git branch with PowerShell


CD Your repository folder

$branch= &git rev-parse --abbrev-ref HEAD 

from Show just the current branch in Git


Try Join-Path

$gitRepo = Join-Path $currentPath ".." -Resolve


Use psget to install the posh-git plugin that shows you the current branch. If you have the latest powershell, chances are that psget is already installed. If you dont have it then get it by using this command.

(new-object Net.WebClient).DownloadString("http://psget.net/GetPsGet.ps1") | iex

To install posh-git use the command:

Install-Module posh-git