Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

  • Installed 'Git for Windows'
  • Replaced the files in cmder/vendor/git-for-windows with the installed files from 'Git for Windows'
  • Tried solutions from git not properly setup in v1.2 #513 and Path issues on startup #487
  • Installed posh-git manually

Problem

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

So how can I fix this?

like image 230
Fabian Schmick Avatar asked Mar 04 '16 21:03

Fabian Schmick


People also ask

How do I enable Posh in git?

To include git information in your prompt, the posh-git module needs to be imported. To have posh-git imported every time PowerShell starts, execute the Add-PoshGitToProfile command which will add the import statement into your $profile script. This script is executed everytime you open a new PowerShell console.

Does posh-git work with git bash?

You can also tab complete remote names and branch names e.g.: git pull or<tab> ma<tab> tab completes to git pull origin master . “ Just to clarify, Git will work both through Git Bash and Posh-Git.


2 Answers

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.

like image 126
Ryan Bemrose Avatar answered Oct 02 '22 03:10

Ryan Bemrose


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() {}

like image 34
Josh Avatar answered Oct 02 '22 04:10

Josh