10

我想从 cmder powershell 使用 git。

错误

Cmder 打印出以下错误:

缺少 git 支持,使用“Install-Module posh-git”安装 posh-git 并重新启动 cmder

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

  • 安装模块 <<<< posh-git
    • CategoryInfo : ObjectNotFound: (Install-Module:String) [], CommandNotFoundException
    • 完全限定错误 ID:CommandNotFoundException

我做过/尝试过的事情

问题

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

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

4

2 回答 2

21

这个答案适用于不需要 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
    #}

注意:对不起,这个答案没有回答查看当前分支的原始请求。我认为这个解决方案可能更适合某些人。

更新:

这是一个更好的解决方案,每次更新 cmder 时都不需要重新应用:

将以下函数添加到 \config\user_profile.ps1(我的巧克力安装文件的完整路径是 c:\tools\cmdermini\config\user_profile.ps1):

function checkGit() {}

于 2017-11-08T20:20:53.883 回答
6

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

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

于 2016-03-04T21:50:22.140 回答