Command 'git.clone' not found

Viewed 9700

I've setup a Windows 10 machine with VSCode and needed to clone a repo so I installed the tooling (Git, NuGet, posh-git and the Environment Variable) using Powershell:

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

Now in VSCode when I try a Git Clone I get an error:

Command 'git.clone' not found

I have git installed as per the Powershell code. I have typed git clone with the space not the dot and same problem.

Also I should note this code worked perfectly about a month ago, so what could the problem be?

3 Answers

It looks like the Git install has changed slightly. In the above code I set the Environment variable for the Git\Bin folder:

 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

That's not where VSCode likes to find the exe. Adding a Environment Variable to C:\Program Files\Git\cmd and not C:\Program Files\Git\bin resolves the problem:

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

If you have a ton of VSCode extensions relating to Git, uninstall them, restart VSCode and try to clone a repo again. Did the trick for me!

Check if you are in Restricted Mode.

In Restricted Mode, Git built-in extension is disabled.

Git extension disabled

Press [️ Restricted Mode] on the bottom left corner of VS Code window.

Where to look

From the Workspace Trust tab that opens, you can choose to trust the current folder or the parent folder.

Learn more about the Workspace Trust here: https://code.visualstudio.com/docs/editor/workspace-trust

Related