繁体   English   中英

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

[英]Missing git support, install posh-git with 'Install-Module posh-git' and restart cmder

我想从cmder powershell中使用git。

失误

Cmder打印出以下错误:

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

如果我运行Install-Module posh-git cmder,则会打印出下一个错误:

  • 安装模块<<<< posh-git
    • CategoryInfo:ObjectNotFound:(安装模块:字符串)[],CommandNotFoundException
    • FullyQualifiedErrorId:CommandNotFoundException

我做过/尝试过的事情

问题

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

那么我该如何解决呢?

此答案适用于不需要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() {}

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM