缺少git支持,使用'Install-Module posh-git'安装posh-git并重启cmder

Fab*_*ian 8 git powershell cmder

我想从cmder powershell使用git.

错误

Cmder打印出以下错误:

缺少git支持,使用'Install-Module posh-git'安装posh-git并重启cmder

如果我运行Install-Module posh-gitcmder打印出下一个错误:

  • 安装模块<<<< posh-git
    • CategoryInfo:ObjectNotFound:(Install-Module:String)[],CommandNotFoundException
    • FullyQualifiedErrorId:CommandNotFoundException

我做过/尝试过的事情

问题

我的git命令正在运行,但没有向我显示我正在处理的分支.

那么我该如何解决这个问题呢?

Jos*_*osh 15

这个答案适用于不需要posh-git的时候.posh-git会对提示的显示造成重大延迟.

在cmder配置文件(\ vendor\profile.ps1)文件中,注释掉函数"checkGit"中的以下行.

function checkGit($Path) {
    #if (Test-Path -Path (Join-Path $Path '.git')) {
    #    $gitLoaded = Import-Git $gitLoaded
    #    Write-VcsStatus
    #    return
    #}
Run Code Online (Sandbox Code Playgroud)

注意:抱歉,此答案无法回答查看当前分支的原始请求.我认为这个解决方案可能更适合某些人.

  • 是的,这是我正在寻找的答案.如果你可以将你的代码块从`<quote>`改为`<code>`那就更好了.您可以通过在每行代码前添加4个空格来完成此操作.为方便起见,使用`<#...#>`(powershell样式注释块)而不是`#`. (2认同)

Rya*_*ose 5

您的 CommandNotFoundException 是因为Install-Module需要 Powershell 3.0,或者PSGet要安装。但是,手动安装应该可以工作。

验证该文件posh-git.psm1是否位于$env:PSModulePath. 然后重新启动 PowerShell 并运行Import-Module posh-git. 这应该会强制它找到模块。