Reputation: 53
I'm trying to use the command git init
. However, I'm getting this error:
git : The term 'git' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ git init
+ ~~~
+ CategoryInfo : ObjectNotFound: (git:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Not sure if it's related to the difference in the locations of the project folder and the git executable but here's the info:
The location of the folder in which I'm working is:
S:\Everything\Coding\modern_portofolio
The location of the git installation is:
S:\Everything\Software\Git
Upvotes: 2
Views: 6654
Reputation: 456
In case it helps someone else who gets sent here via google: I was having this issue, but the standard "reinstall git" and "fix your PATH" advice wasn't working for me. My problem turned out to be unrelated to git specifically, but my symptoms were as follows:
git
in Powershell: The term 'git' is not recognized as the name of a cmdlet....\git.exe
in Powershell: command prompt opens and immediately closes, no error or response at all in Powershellgit
in Command Prompt: everything works normallyIf you don't have those symptoms, then this probably isn't going to help you, but for those who do...
Open up your Environment Variables (Start -> Edit the System Environment Variables -> Environment Variables...), and make sure that you have one named PATHEXT in the "System variables" group box. The default values for Windows 10 are as follows:
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
Somehow mine had gotten cleared out. Setting PATHEXT to that and then restarting Powershell/VSCode solved the issue.
Upvotes: 0
Reputation: 1325155
Try and launch your VSCode from a CMD session where your PATH was correctly setup.
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%
Then the git
command should be recognized from within VSCode console, be it a PowerShell one or any other.
Upvotes: 1