我想在 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
我做过/尝试过的事情
- 安装了“Windows 版 Git”
- 将
cmder/vendor/git-for-windows
中的文件替换为“Git for Windows”中安装的文件 - 来自 git not properly setup in v1.2 #513 的尝试解决方案和 Path issues on startup #487
- 手动安装 posh-git
问题
我的 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/