If you use Cmder and installed posh-git with Chocolatey (instead of Install-Module
), you'll get this message when you navigate to a Git repository in a Cmder PowerShell tab:
C:\any\git\repoWARNING: Missing git support, install posh-git with 'Install-Module posh-git' and restart cmder.
To fix this, add the following to the bottom of the Chocolatey user_profile.ps1
at C:\tools\cmdermini\config\user_profile.ps1
(or C:\tools\cmder\config\user_profile.ps1
if you installed the full version):
function Import-ChocolateyPoshGitModule {
if (Get-Module posh-git) { return $true }
$pathPattern = "C:\tools\poshgit\dahlbyk-posh-git*\src\posh-git.psd1"
if (-not (Test-Path $pathPattern)) { return $false }
$modulePath = (Resolve-Path $pathPattern).Path
Import-Module $modulePath
return $true
}
# Cmder will not try to import posh-git when $gitLoaded is true
$gitLoaded = Import-ChocolateyPoshGitModule
The Chocolatey posh-git package updates your PowerShell profile (%USERPROFILE%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
) to automatically import posh-git when you open a new PowerShell terminal. Cmder uses its own profile (found at C:\tools\cmdermini\vendor\profile.ps1
) that tries to import posh-git, but it fails because it isn't aware of the Chocolatey posh-git package location. Thus the Missing git support message.
The snippet above imports posh-git from the Chocolatey path and tells Cmder not to try to load it again. user_profile.ps1
isn't modified when Cmder is updated (unlike profile.ps1
), so this change will persist between Cmder updates.