简体   繁体   English

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

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

I want to work with git, from the cmder powershell. 我想从cmder powershell中使用git。

Errors 失误

Cmder prints out the following error: Cmder打印出以下错误:

Missing git support, install posh-git with 'Install-Module posh-git' and restart cmder 缺少git支持,请使用“安装模块posh-git”安装posh-git并重新启动cmder

If I run the Install-Module posh-git cmder prints out the next error: 如果我运行Install-Module posh-git cmder,则会打印出下一个错误:

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

Things I have done/tried 我做过/尝试过的事情

Problem 问题

My git commands are working, but not showing me the branch I am working on. 我的git命令正在运行,但是没有显示我正在处理的分支。

So how can I fix this? 那么我该如何解决呢?

This answer is for when posh-git is not wanted. 此答案适用于不需要posh-git的情况。 posh-git can introduce significant delays to the prompt's display. posh-git可能会大大延迟提示的显示。

In the cmder profile (\\vendor\\profile.ps1) file, comment out the following lines in the function "checkGit". 在cmder配置文件(\\ vendor \\ profile.ps1)文件中,在函数“ checkGit”中注释掉以下几行。

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

Note: Sorry, this answer doesn't answer the original request to see the current branch. 注意:很抱歉,此答案无法回答查看当前分支的原始请求。 I think that this solution may be a better fit for some people. 我认为这种解决方案可能更适合某些人。

Update: 更新:

Here's a better solution that won't need to be reapplied every time that cmder is updated: 这是一个更好的解决方案,不需要在每次更新cmder时重新应用它:

Add the following function to \\config\\user_profile.ps1 (the full path for my chocolatey installation file is c:\\tools\\cmdermini\\config\\user_profile.ps1): 将以下功能添加到\\ config \\ user_profile.ps1(我的巧克力状安装文件的完整路径为c:\\ tools \\ cmdermini \\ config \\ user_profile.ps1):

function checkGit() {}

Your CommandNotFoundException is because Install-Module requires Powershell 3.0, or PSGet to be installed. 您的CommandNotFoundException是因为Install-Module需要Install-Module Powershell 3.0或PSGet However, the manual install should work. 但是,手动安装应该起作用。

Verify that the file posh-git.psm1 is located somewhere in $env:PSModulePath . 验证文件posh-git.psm1是否位于$env:PSModulePath Then restart PowerShell and run Import-Module posh-git . 然后重新启动PowerShell并运行Import-Module posh-git This should force it to find the module. 这应该迫使它找到模块。

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

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