【问题标题】:Powershell/PoshGit - 'Could not find ssh-agent'Powershell/PoshGit - '找不到 ssh-agent'
【发布时间】:2015-12-30 23:00:25
【问题描述】:

我已经从https://code.google.com/p/msysgit/downloads/list?q=full+installer+official+git 安装了Git 版本Git-1.8.3-preview20130601.exe。我还安装了 PoshGit,并且正在使用 Windows PowerShell。

当我启动 PowerShell 时,我得到了

警告:找不到 ssh-agent

我可以在命令行中输入ssh-agent.exe 并启动 ssh 代理。我还能够执行所有 Git 命令,所以我的 Git 路径可能是正确的。

我一直关注this guide 以使 Git 在 Windows 中正常工作。

我已经尝试过他将$env:path += ";" + (Get-Item "Env:ProgramFiles(x86)").Value + "\Git\bin" 添加到我的 Microsoft.PowerShell_profile.ps1 文件中的建议,但没有奏效。它没有任何区别。我正在寻找除该解决方案之外的其他建议。


为了完整起见,这是我的 Microsoft.PowerShell_profile.ps1 文件

# Load posh-git example profile
. 'C:\Users\________\code\posh-git\profile.example.ps1'
$env:path += ";" + (Get-Item "Env:ProgramFiles(x86)").Value + "\Git\bin"

【问题讨论】:

    标签: git powershell


    【解决方案1】:

    您只需在 Microsoft.PowerShell_profile.ps1 中反转这两行,以便更新 PATH 环境变量以包含 Git bin 路径您包含 posh-git 配置文件。 p>

    在我的 PC 上是这样的:我启动 PowerShell 并收到警告消息:

    WARNING: Could not find ssh-agent
    

    我使用$profile 找到并编辑 PowerShell 配置文件:

    C:\Users\glombard> notepad $profile
    

    在加载 posh-git 示例配置文件之前更新 $env:path 以包含 git 的路径:

    $env:path += ";${env:ProgramFiles(x86)}\Git\bin"
    
    # Load posh-git example profile
    . 'C:\tools\poshgit\dahlbyk-posh-git-22f4e77\profile.example.ps1'
    

    【讨论】:

    • 我在这里找到了正确的Microsoft.PowerShell_profile.ps1C:\Users\[YourUserName]\Documents\WindowsPowerShell
    • 在我的例子中,我将 git 路径添加到 System PATH 环境变量中,这样我也可以从命令控制台获得 git 命令。
    【解决方案2】:

    您也可以只进行Chocolatey 升级或重新安装 Posh Git。 choco install poshgit 或者 choco upgrade poshgit

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-03
      • 2020-02-17
      • 2021-10-30
      • 2023-01-13
      • 2016-10-17
      • 2020-10-09
      • 1970-01-01
      • 2022-08-16
      相关资源
      最近更新 更多