How can I display my current git branch name in my PowerShell prompt?

前端 未结 7 2109
暗喜
暗喜 2020-11-30 20:18

Basically I\'m after this but for PowerShell instead of bash.

I use git on windows through PowerShell. If possible, I\'d like my current branch name to displayed as

7条回答
  •  半阙折子戏
    2020-11-30 20:48

    With Git 2.22 (Q2 2019), any script (Powershell or not) could use the new --show-current option.

    $branch = git branch --show-current
    

    If empty, it means "detached HEAD".

提交回复
热议问题