Add Current Git Branch to Windows PowerShell Prompt

  1. Run PowerShell.
  2. Type the following to get the profile folder location: echo $PROFILE. NOTE: if you want to make a change beyond just the local user and system, use one of the parameters here.
  3. Create a file in this location, it it doesn’t exist.
  4. In this file, enter the following:
    function prompt {
        $branch = git branch --show-current
        if ($LASTEXITCODE -ne 0) {
            "PS $(Get-Location)>"
        "PS $(Get-Location) (git:$branch)"
  5. Go to a folder with a git repository, and verify that the current branch is shown.

Leave a Reply