找不到命令'git.clone'

时间:2019-10-16 23:34:02

标签: git visual-studio-code git-clone

我已经使用VSCode设置了Windows 10计算机,并且需要克隆存储库,因此我使用Powershell安装了工具(Git,NuGet,posh-git和环境变量):

iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco install git -y

#devlog('Install NuGet, Git, SSH Keys directory and set region')
$newPath = "$($env:PATH)C:\Program Files\Git\bin;"
[Environment]::SetEnvironmentVariable( 'PATH', $newPath, "Machine")
$env:PATH = $newPath
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
install-module posh-git -force

当我尝试Git克隆时,现在在VSCode中出现错误:

  

找不到命令'git.clone'

我已经按照Powershell代码安装了 git 。我用空格而不是点和相同的问题键入了git clone

另外,我应该注意到这段代码在一个月前运行良好,那可能是什么问题呢?

1 个答案:

答案 0 :(得分:0)

Git安装似乎已略有变化。在上面的代码中,我为Git \ Bin文件夹设置了环境变量:

 Directory of C:\Program Files\Git\bin

10/16/2019  10:34 PM    <DIR>          .
10/16/2019  10:34 PM    <DIR>          ..
08/17/2019  09:27 AM            43,616 bash.exe
08/17/2019  09:27 AM            43,096 git.exe
08/17/2019  09:27 AM            43,616 sh.exe

那不是VSCode喜欢找到该exe的地方。将环境变量添加到 C:\ Program Files \ Git \ cmd 而不是 C:\ Program Files \ Git \ bin 即可解决问题:

enter image description here

Directory of C:\Program Files\Git\cmd

10/16/2019  10:34 PM    <DIR>          .
10/16/2019  10:34 PM    <DIR>          ..
08/17/2019  09:27 AM           151,136 git-gui.exe
08/17/2019  09:27 AM            43,096 git-lfs.exe
08/17/2019  09:27 AM            43,096 git.exe
08/17/2019  09:27 AM           151,128 gitk.exe
08/17/2019  09:27 AM             3,022 start-ssh-agent.cmd
08/17/2019  09:27 AM             2,723 start-ssh-pageant.cmd