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

标签 git powershell cmder

我想在 cmder powershell 中使用 git。

错误

Cmder 打印出如下错误:

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

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

  • Install-Module <<<< posh-git
    • CategoryInfo : ObjectNotFound: (Install-Module:String) [], 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(我的chocolatey安装文件的完整路径是c:\tools\cmdermini\config\user_profile.ps1):

函数 checkGit() {}

关于git - 缺少 git 支持,使用 'Install-Module posh-git' 安装 posh-git 并重新启动 cmder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35806066/

相关文章:

GitHub 克隆错误 : Cannot clone with EOF error

git - 通过 SSH 克隆让服务器认为 GIT 的主目录是文件系统的根目录?

powershell - 第一次调用 msbuild 挂起

powershell - 您必须在 '-' 运算符之后提供值表达式

shell - 如何打开 shell 然后在其中执行命令

git - gitlab本地 merge 后无法推送

git - 在Jenkins中从Gradle脚本调用Git时发生错误

c# - Powershell v4 不自动导入模块

linux - 删除所有 node_modules 子文件夹

conemu - 自Windows更新以来,Conemu不适用于wsl