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

2

11

I want to work with git, from the cmder powershell.

Errors

Cmder prints out the following error:

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

If I run the Install-Module posh-git cmder prints out the next error:

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

Things I have done/tried

Problem

My git commands are working, but not showing me the branch I am working on.

So how can I fix this?

Nonresistant answered 4/3, 2016 at 21:9 Comment(7)
"Installed posh-git manually" <-- What did you do here?Agnusago
Also, what version of PowerShell are you running? Install-Module requires 3.0 or later.Agnusago
I followed the Installing (manual) guide for posh git here: link My PowerShell Version is Version 2.0 -> so I will try to update Powershell and run that command Install-Module posh-git againNonresistant
Possible duplicate of The term 'Install-Module' is not recognized as the name of a cmdletAgnusago
Your CommandNotFoundException is because Install-Module requires Powershell 3.0, or PSGet to be installed. However, the manual install should work. Verify that the file posh-git.psm1 is located somewhere in $env:PSModulePath.Agnusago
Also, on a whim, try restarting PowerShell after running install.ps1, if you haven't already. Then run Import-Module posh-gitAgnusago
I updated my Powershell and run the commend again, now it works just fine. Thank you for your help :)Nonresistant
A
6

Your CommandNotFoundException is because Install-Module requires Powershell 3.0, or PSGet to be installed. However, the manual install should work.

Verify that the file posh-git.psm1 is located somewhere in $env:PSModulePath. Then restart PowerShell and run Import-Module posh-git. This should force it to find the module.

Agnusago answered 4/3, 2016 at 21:50 Comment(0)
P
22

This answer is for when posh-git is not wanted. posh-git can introduce significant delays to the prompt's display.

In the cmder profile (\vendor\profile.ps1) file, comment out the following lines in the function "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:

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):

function checkGit() {}

Pforzheim answered 8/11, 2017 at 20:20 Comment(3)
Yes, this is the answer I'm looking for. If you could change your code block from <quote> to <code> it would be better. You can do this by adding 4 space before each line of code. And for convenience, use <# ... #>(powershell style comment block) instead of #.Isoagglutination
THANKYOU! This has been driving me nuts for months.Plymouth
Instead of disabling posh-git altogether, you can also $GitPromptSettings.EnableFileStatus = $false to turn off the git status check for every prompt without losing most tab expansion.Toadinthehole
A
6

Your CommandNotFoundException is because Install-Module requires Powershell 3.0, or PSGet to be installed. However, the manual install should work.

Verify that the file posh-git.psm1 is located somewhere in $env:PSModulePath. Then restart PowerShell and run Import-Module posh-git. This should force it to find the module.

Agnusago answered 4/3, 2016 at 21:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.